How to save position after reload DataGridView
Posted
by bobik
on Stack Overflow
See other posts from Stack Overflow
or by bobik
Published on 2010-03-14T14:12:35Z
Indexed on
2010/03/14
14:15 UTC
Read the original article
Hit count: 223
c#
|datagridview
this is my code:
private void getData(string selectCommand)
{
string connectionString = @"Server=localhost;User=SYSDBA;Password=masterkey;Database=C:\data\test.fdb";
dataAdapter = new FbDataAdapter(selectCommand, connectionString);
DataTable data = new DataTable();
dataAdapter.Fill(data);
bindingSource.DataSource = data;
}
private void button1_Click(object sender, EventArgs e)
{
getData(dataAdapter.SelectCommand.CommandText);
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bindingSource;
getData("SELECT * FROM cities");
}
after reload data on button1 click, cell selection jumps on first column and scrollbars is reset. How to save position of DataGridView?
© Stack Overflow or respective owner