Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagrid row problem
 

Datagrid row problem

Hi

I do not want the cell to highlight when clicked on, i want the cursor to go in immediatly. So i set "editmode" to EditOnEnter. So as soon as you enter the cell it places the cursor there and you see no highlighting.

But now if i add values to cells through code it is then highlighted. I need it to be always with just the cursor in the cell. Any other way??? Is there a way to simulate a click on that cell or select that cell or make that cell with focus????

Another problem is when i add my value to the column then try to add a row using the following dtgrdGetHandle.Rows.Insert(1, 1); i get an error "No row can be inserted after the uncommitted new row." Why??

Thanks in advance

LuckyL  Wednesday, December 20, 2006 7:26 PM

this does the trick.

Me.DataGridView1.CurrentCell = Me.DataGridView1(a, b)

Me.DataGridView1(a, b).Value = "Something"

Me.DataGridView1.BeginEdit(True)

 

now for your new new row, (extract from FAQ)

No row can be added after the row for new records. An InvalidOperationException is raised if this is attempted. As a result, the row for new records is always the last row in the DataGridView control. The methods on DataGridViewRowCollection that add rows—Add, AddCopy, and AddCopies—all call insertion methods internally when the row for new records is present.

 

4.1.3.4 Typing in the New Row

Before a user starts to type in the new row the row’s IsNewRow property returns true. When the user starts to type in the new row, that row no longer is considered the new row, but a "new" new row is added:

hrubesh  Thursday, December 21, 2006 6:29 AM

this does the trick.

Me.DataGridView1.CurrentCell = Me.DataGridView1(a, b)

Me.DataGridView1(a, b).Value = "Something"

Me.DataGridView1.BeginEdit(True)

 

now for your new new row, (extract from FAQ)

No row can be added after the row for new records. An InvalidOperationException is raised if this is attempted. As a result, the row for new records is always the last row in the DataGridView control. The methods on DataGridViewRowCollection that add rows—Add, AddCopy, and AddCopies—all call insertion methods internally when the row for new records is present.

 

4.1.3.4 Typing in the New Row

Before a user starts to type in the new row the row’s IsNewRow property returns true. When the user starts to type in the new row, that row no longer is considered the new row, but a "new" new row is added:

hrubesh  Thursday, December 21, 2006 6:29 AM

You can use google to search for other answers

Custom Search

More Threads

• Is there BeginUpdate() functionality for the DataGridView?
• asp.net c# .DataSource, .DataMember, .DataTextField, .DataValueField, .DataBind
• DataGrid Column won't resize to 0
• Listbox does not show Bound data?
• DEAR JACOBMVP
• formatting goes off when a column in datagridview is sorted.
• DataGridView and objectdatasource
• DatagridviewComboboxColumn Draw Text Only
• Memo Field being cut off
• DataGridView: how to stop / cancel sorting