Hi all,
Is anyone know how to make the cursor flashing inside the new record or the selected record?
I using XamDatagrid version 9.1. I have a grid and also a button new and edit.
those are code I using in button new:
xamDataGrid.FieldLayoutSettings.AllowAddNew = true;
(xamDataGrid.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsActive = true;(xamDataGrid.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsSelected = true; xamDataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode);
with that code, the new record added and selected, but the cursor won't flashing in it.
It also happen if I click edit button.
those are code I using in button edit :
xamDataGrid.FieldLayoutSettings.AllowEdit = true;
(xamDataGrid.ActiveRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsActive = true;(xamDataGrid.ActiveRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsSelected = true; xamDataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode);
with that code, the selected record is in edit mode and selected, but the cursor won't flashing in it.
I need to click on the record first to make to cursor flashing inside the record.
Is there anyone know how to solved this?
Thanks before,
Vera
Hell Vera,
I suppose you are referring to the Caret of the XamTextEditor. The "cursor" is the mouse cursor and it cannot be flashing. The caret is not showing, because when the XamTextEditor enters EditMode, the text inside it is selected. If you want the caret to appear when you hit that button, you have to de-select the text.
You can do this by getting the CellValuePresenter of that cell and set the SelectionLength of the Editor.
Here is how to do this (this will place the caret in the beginning of the XamTextEditor):
(CellValuePresenter.FromCell(xamDataGrid1.ActiveCell).Editor as XamTextEditor).SelectionLength = 0;
Hi Alex. Thanks for your answer.
The problem that I facing now is I want to select the record inside the cell. But what happen now is : the cell is selected instead of the record. How to make it the cell is active and also the record inside the cell?
why if I try to make the currentAddRecord(which is now I set it to active record) to selected = true is always return false?
(xamDataGrid1.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid1.FieldLayouts[0].Fields[0]].IsSelected = true;(xamDataGrid1.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid1.FieldLayouts[0].Fields[0]].IsActive = true; xamDataGrid1.ActiveRecord.IsSelected = true; // the active record now is the currentAddReoord, but why this is always return false?
Thanks
Vera,
You can use the CellClickAction property to select the record that the cell belongs to.
...
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings CellClickAction="SelectRecord" />
</igDP:XamDataGrid.FieldSettings>
You can also use DataPresenterCommands like :
xamDataGrid1.ExecuteCommand(DataPresenterCommands.RecordFirstOverall);
Alex.
Hi ALex,
Thanks for your help. from your code, I modified it and found if I using this, the cursor will be flashing on the cell.
(CellValuePresenter.FromCell(xamDataGrid1.ActiveCell).Editor as XamTextEditor).Focus(); (CellValuePresenter.FromCell(xamDataGrid1.ActiveCell).Editor as XamTextEditor).IsInEditMode = true;
Regards,