Click here to Skip to main content
12,398,225 members (53,231 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL-Server
once if i insert data in datagridview selection point need to go to the top any help
Posted 4-Feb-13 2:53am
Updated 4-Feb-13 3:05am
v2
Comments
JemiM 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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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

Hope this helps
  Permalink  
Comments
Edo Tzumer 4-Feb-13 10:47am
   
5+
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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;
  Permalink  
Comments
selva_1990 4-Feb-13 9:16am
   
its not working Rohit :( any other way
Krunal Rohit 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
Krunal Rohit 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100