On form load i want a select all text in a particular cell value.
Here is my code, and cell is editable by user
ugPayments.ActiveCell = ugPayments.Rows(i).Cells(4)
ugPayments.ActiveCell.Selected =
True
ugPayments.ActiveCell.SelectAll()
But it is throwing me an error saying
Operation cannot be performed when not in edit mode.
I think that this has to do with a timing issue of the form loading and the grid not being able to take focus. Try entering edit mode through a BeginInvoke so that the loading operation can complete:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Me.ultraGrid1.ActiveCell = Me.ultraGrid1.Rows(0).Cells(0) Me.ultraGrid1.ActiveCell.Selected = True Me.BeginInvoke(New MethodInvoker(Me.EnterAndSelectText)) End Sub Private Sub EnterAndSelectText() Me.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode) Me.ultraGrid1.ActiveCell.SelectAll() End Sub
-Matt
Thanks! I tried your advice as follows
ugPayments.PerformAction(UltraGridAction.EnterEditMode)
But still I am getting the error 'Operation can not be performed when not in edit mode.'
I think that you're confusing the Seleted state of a cell with actually selecting the text in the editor. If you want to always select the text when the user enters edit mode you could do something like:
private void ultraGrid1_AfterEnterEditMode(object sender, EventArgs e){ this.ultraGrid1.ActiveCell.EditorResolved.SelectAll();}
If you want to programmatically enter edit mode:
this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);