Hi Friends,In my UltraGrid I use the following code to set the active cell :-
ultraGridMass.ActiveCell = ultraGrid.Rows[0].Cells[1];
When I do this the cell gets focus but I can not directly edit the cellbefore clicking it once with the mouse....I want to be able to directly startediting the cell. How do i accomplish that ?Looking for help...
Thanks Sid.
Hi Sid,
In addition to setting the ActiveCell, you may need to set focus to the grid. Then you will need to call:
grid.PerformAction(EnterEditMode)
Note that this will not work in the Form_Load event, since you cannot set focus to a control inside that event. If that's the case, you may be able to work around it using a BeginInvoke.
I'm doing this, but it's not working when adding the first row, my code is the following:
private void btnAddField_Click(object sender, EventArgs e)
{
if (dgAttributes.Rows.Count == 0 || IsValid())
var dgRow = dgAttributes.DisplayLayout.Bands[0].AddNew();
dgAttributes.ActiveRow = dgRow;
var dgCell = dgRow.Cells[0];
dgAttributes.ActiveCell = dgCell;
dgAttributes.Focus();
dgAttributes.PerformAction(UltraGridAction.EnterEditMode, false, false);
}
After adding the first row, the cursor is correctly set, but not for the first row that's added.
Hi,
I don't see anything wrong with this code what would explain the behavior you are getting. There's no difference between the first row and any other row. My best guess is that something else in your code is causing this. Perhaps you are handling some other event of the grid and doing something in response to the first row being added?
Are you certain that the cell is not actually entering edit mode? Sometimes, in a case like this, it appears that the cell did not enter edit mode, but what really happens is that it enters edit mode and the immediately exits edit mode. So you might want to add some Debug.Writeline's into the grid's BeforeEnterEditMode, AfterEnterEditMode, BeforeExitEditMode, and AfterExitEditMode events to see exactly what is happening. If the grid is entering and the exiting edit mode, putting a breakpoint in BeforeExitEditMode and looking at the call stack can help you figure out why it's happening.
Also, you might try checking the return value of the PerformAction method. Is it returning true or false?
It's not, not for the first row that's inserted. I still have to click the cell to begin entering information. From the second row foreword, there's no problems and the cursor is correctly set in the desired cell