DataGridView FirstDisplayedScrollingRowIndex无法正常工作? [英] DataGridView FirstDisplayedScrollingRowIndex not working?
本文介绍了DataGridView FirstDisplayedScrollingRowIndex无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在datagridview的最后一行显示。为此我在Form_Load()中使用。
它是否正确或我必须在不同的事件中使用它?
Hi,
I wish to display at the last row of datagridview. For that I used in Form_Load().
Is it correct or I have to use it in different event?
Form_Load()
{
myDataGrid1.FirstDisplayedScrollingRowIndex=250;
myDataGrid1.Rows[250].Selected = true;
myDataGrid1.Rows[250].Cells[0].Selected = true;
}
注意:我在几年前找到了一个解决方案,但我忘记了这一点
感谢您的指示
Note: I found a solution before few years, but I forget the point
Thanks for the directions
推荐答案
您好b $ b
您可以在将数据源分配到datagridview后使用这些代码...
u可以将这些代码粘贴到
Hi
you can use these codes after you r assigning datasource to the datagridview...
u can paste those codes next to
myDataGrid1.DataSource = dt // some data source...
它会正常工作......测试....
示例代码::
it will work fine... tested....
example code ::
DataTable dt = new DataTable();
dt.Columns.Add("column1", typeof(string));
for (int i = 0; i < 15; i++)
dt.Rows.Add("value " + i);
dataGridView1.DataSource = dt;
dataGridView1.FirstDisplayedScrollingRowIndex = 10;
dataGridView1.Rows[10].Selected = true;
dataGridView1.Rows[10].Cells[0].Selected = true;
谢谢..但是它不起作用,你稍后删除并添加列...所以将上面的行改为DataGridView1_GotFocus( )..事件,它工作正常。
Thanks..But It doesn't work, while you remove & add columns later...So changed the above lines to DataGridView1_GotFocus()..event, it works fine.
这篇关于DataGridView FirstDisplayedScrollingRowIndex无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文