Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
once if i insert data in datagridview selection point need to go to the top any help
Posted
Updated 4-Feb-13 3:05am
v2
Comments
Jameel VM 4-Feb-13 8:56am    
top means?u want to focus any textBoxes after insertion?
selva_1990 4-Feb-13 8:59am    
nope... suppose if i am having 9 rows in data gridview and now adding 10th data after adding this, the selection pointer need to go to first data in datagrid

Try this
C#
dgridView.CurrentCell = dgridView.Rows[0].Cells[0];


Hope this helps
 
Share this answer
 
Comments
Joezer BH 4-Feb-13 10:47am    
5+
See :
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindex.aspx[^]

or else, after Inserting data try
dataGridView1.Rows[0].Selected = true;
 
Share this answer
 
Comments
selva_1990 4-Feb-13 9:16am    
its not working Rohit :( any other way
[no name] 4-Feb-13 9:18am    
Try, dataGridView1.SelectedIndex = 1;
Maybe it work !
selva_1990 4-Feb-13 9:23am    
Error 1 'System.Windows.Forms.DataGridView' does not contain a definition for 'SelectedIndex' and no extension method 'SelectedIndex' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?) if add this getting error
[no name] 4-Feb-13 9:29am    
Ok ok, it is for Form App...
Try to change color :
GridView1.Rows[1].BackColor = System.Drawing.Color.Blue;
selva_1990 4-Feb-13 9:36am    
again its throwing error ji

Error 1 'System.Windows.Forms.DataGridViewRow' does not contain a definition for 'BackColor' and no extension method 'BackColor' accepting a first argument of type 'System.Windows.Forms.DataGridViewRow' could be found (are you missing a using directive or an assembly reference?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900