How to scroll programmatically to a row in the DataGridView ?(windows applications)

Posted by Sudheep.grandhe under C# on 12/1/2011 | Points: 10 | Views : 7051 | Status : [Member] | Replies : 1
Hi,

i wrote the code for How to scroll programmatically to a row in the DataGridView. there is no errors but i dont no whether it is working or not .how can i confirm it is working.

private void UpdateCustomerName_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
selectQueryString = "select * from tbl_customer";
conn.Open();
sqlDataAdapter = new SqlDataAdapter(selectQueryString, conn);
sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);
dataTable = new DataTable();
sqlDataAdapter.Fill(dataTable );
bindingSource = new BindingSource();
bindingSource.DataSource = dataTable;
dataGridView1.DataSource = bindingSource;
int jumptorow = 10;
if (dataGridView1.Rows.Count >= jumptorow && jumptorow >= 1)
{
dataGridView1.FirstDisplayedScrollingRowIndex = jumptorow;
dataGridView1.Rows[jumptorow].Selected = true;
}
}

Best,
Sudheep.



Responses

Posted by: Naraayanan on: 2/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
It works.

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response