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
Hello Mike
I have now also tried the enter event with the same result. But I would prefer to have the code regarding row insert in the click event for the "Insert Button".
I tried with insert new row in the insert button click event, and moved the activation of cell and PerfomAction in the enter event.
Some observation:
1) Then enter event is not fired unless I do a grid.Focus() in the button click event.
2) If I have not mouse clicked the grid, and then clicked the insert button: The enter event is fired once for each button click event because of the grid.Focus()
3) If I first have mouse clicked on the grid, and then clicked the insert button: The Enter event is also fired when the PerfomAction(EnterEditMode) is called within the Enter event.
Hi Frank
I don't quit understand how I can use the Shown edit, as I can see this event is only fired when the form is shown for the first time?
So... you are saying that the cell is not entering edit mode, even if you do not set the SelStart?
As I said, this worked fine for me when I did it. Are you using the same event I did - the Enter event?
hi maggreen,
I had the same problem like you today. My solution is: I put the code to add a new row into the grid into the Shown event of the form and then all is fine. Try this, perhaps it helps. As Mike said it seams to me like a timing issue.
My original reason for including the SelStart was that I had the same problem as maggreen a few weeks ago. Yeah it appears the ActiveRow and ActiveCell setting works, but when the EnterEditMode action is performed, you only get a cell that selected, but not in edit mode.
If you execute the executable sample in this directory:
"C:\Documents and Settings\All Users\Documents\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Samples\Win\WinGrid\Tutorial2\Cell Activation\bin"
The cell in this datatable enters edit mode with no problem. I'm not sure if there's a difference in the VB and C# interpretation of the Infragistics controls, but it should work exactly the same. In my case it doesn't so I had to use SelStart to get the cell into edit mode.