clwn.net
当前位置:首页 >> DAtAgriDviEw添加行号 >>

DAtAgriDviEw添加行号

获取datagridview行号和列号,参考实例和注解如下: private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) { iTag = (int)this.Tag; //if (iTag == 4) //{ // if (e.ColumnIndex ==3) // MessageBox.Show("该列为...

public Form1(){ InitializeComponent(); this.dataGridView1 .RowsAdded+=new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);}private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e){ for (i...

int j = 0; for (int i = 0; i < dataGridView.Rows.Count; i++) { j = i + 1; dataGridView.Rows[i].HeaderCell.Value = j.ToString(); }

你那方法明显有很大的问题,如果我删除一行呢?如果我不暗规矩乱删除一行你怎么办? private void RefreshDataGridViewLineNumber(int index) { for (int i = index; i < dataGridView1.Rows.Count; i++) { this.dataGridView1.Rows[i].HeaderCe...

一般不用它显示,设置showrowheader为false隐藏它,自己建一列显示行号

this.dataGridView1.Columns[0].Name = "序号 "; for (int i = 1; i < this.dataGridView1.Rows.Count; i++) { this.dataGridView1.Rows[i-1].Cells[0].Value = i; }

控件添加如下事件即可在*号那个位置显示序号: //datagridview添加行号 private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e) { e.Row.HeaderCell.Value = (e.Row.Index + 1).ToString(); }至于...

DataGridView.CurrentCell.RowIndex;C#.NET的是这么写的,VB的也差不多吧

e.RowIndex 。。。。

把下面的代码放到Form_Load事件中,运行的时候就会显示了: int index=this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = "1"; this.dataGridView1.Rows[index].Cells[1].Value = "2"; this.dataGridView1.Rows[...

网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com