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 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);
-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.'
The code is very simple. I have a ultragrid on form and I have one column editable by user. On form load I want to select the text that the cell has. Basically it is a Sales Receipt Payment Form. Cashier has to take payment. The picture will explain more, I believe
The code I have is
Me.BeginInvoke(New MethodInvoker(AddressOf EnterAndSelectText))
Private Sub EnterAndSelectText()
Me.ugPayments.PerformAction(UltraGridAction.EnterEditMode)
Me.ugPayments.ActiveCell.SelectAll()
End Sub
I can modify the code to avoid error as follows, but it will not select the text in cell
Private
Sub EnterAndSelectText()
If Me.ugPayments.PerformAction(UltraGridAction.EnterEditMode) Then
End If
The only time I really see the EnterEditMode action fail is when the grid fails to gain focus, which is why I tried using a BeginInvoke to get around that. Ensure that invoking this method is the very last thing that you do in the form's Load event; you may even try explicitly setting focus to the grid after calling PerformAction, though this is done implicitly. If this still doesn't work, it's likely a timing issue. For example, does this code work if you add a button to the form and execute the code in the Click event? If it does, then it definitely is a timing issue with the form not allowing the grid to take focus quite yet. Perhaps if this is the case, you could start another thread, have a timer wait a second on that thread, then invoke the code to enter edit mode back to the main thread.
As for version numbers, the main version should be part of your reference (i.e. Infragistics2.Win.v8.2.dll). The actual build number is the last 4 digits in the Version field in the PropertyGrid when looking at the properties of that particular DLL.
I have Infragistics2.Win.v8.3.20083.1009. I googled and got this link for a hot fix. I don't know if it applies to my version.
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9678
That is an older version of NetAdvantage, so if you're experiencing the same error as outlined in that KB article, it should be fixed already since it was done a while ago. I'm still not certain that it's the same error, however. You should probably submit a sample to Developer Support so that they can look further into it.
If you do want to try the latest version before submitting the issue, you could get the latest service release here.
Hi, I know this is old, but wanted to share what worked for me
'->without e.Handled = True, SelectAll does not seem to work
Private Sub UltraGrid1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltraGrid1.KeyDown
Try
If e.KeyCode = Keys.Down Then
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, False, False)
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.BelowCell, False, False)
e.Handled = True '->sin esta instrucción, no se selecciona el contenido de la celda
If UltraGrid1.ActiveRow.Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit Then
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, False, False)
If UltraGrid1.ActiveCell.IsInEditMode Then UltraGrid1.ActiveCell.SelectAll()
ElseIf e.KeyCode = Keys.Up Then
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell, False, False)
ElseIf e.KeyCode = Keys.Left Then
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.PrevCell, False, False)
ElseIf e.KeyCode = Keys.Right Then
UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextCell, False, False)
Catch ex As Exception
MsgBox(ex.Message & " " & Me.Name & " -UltraGrid1_KeyDown(")
End Try
'mariela pez