I try to insert a new row in a grid and then set a cell automatically to edit mode. The row is inserted via databinding to a business object, and not directly to the grid. The row is highlighted but no cell is in edit mode. If I first click on the grid and then inserts a new row it works for every new row thereafter. It's look like I am missing something the mouseclick do. A row insert is done by adding a new business object, and I deal with the new row in InitializeRow like this:
{
e.Row.Activate();
grid.ActiveCell = aCell;
}
The PerformAction seems to have no effect. If I click the grid first, it works as expected.
Some suggestion?
Kind Regards
Magnus
Oslo, Norway
Yes it is very odd. I am using selStart only because of a tip earlier in this tread. That is not my main problem but only a sympton, the problem is to get the cell in editmode.
Hm, that's odd. This worked fine for me.
Perhaps it's a timing issue and the cell has no entered edit mode by the time SelStart is being set. Maybe you need to use BeginInvoke to call a method that sets the SelStart on the active cell of the grid.
Why set SelStart, anyway? Setting it to 0 is redundant - it will already be 0 when it enters edit mode.
The ActiveCell is not set in EditMode. If I use SelStart= 0 , i got an error message ".... not in EditMode". So the PerfomAction have no effect.
But if I mouseclick the grid before adding a row it works, and it will work for all rows inserted thereafter.
Assuming you BOCollection is an IBindingList and notifies the grid that a new row has been added, this should not make any difference at all. The code I posted here works fine for me. What's not working for you?
Yes, I agree. I have moved all the code regarding row insert into the button_click. See my earlier post today. But it has no effect on the result.
The biggest difference in your example is when inserting rows:
DataRow row = this.dt1.NewRow(); this.dt1.Rows.Add(row);
But I use something like this to insert a new row:
BOCollection.Add(New BOItem(id))
Where BOCollection og BOItem is business objects.