Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Editing WinGrid When Tabbing Into Focus
posted

I have a wingrid which is set to allow me to edit the data in the cells. When I tab through my form and reach my grid I want to enter the grid (adding an initial row if there are none already) and go into edit mode on the first cell of the grid. So far I have managed the majority of this, however I am having trouble getting the cell to go straight into edit mode. When I tab into the grid the first row is selected (or added) and the first cell is selected/activated, however I cannot seem to get the cell to go straight to edit mode (giving me the cursor) without me actually clicking the cell with the mouse.

Below is the code I am using for entering the grid. the code is actually located in a custom class which inherits the grid and adds some default functionality as required in my application.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Private Sub StUltraEditGrid_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase

.GotFocus

EnterEditGrid()

 

 

End

Sub

 

 

Public Sub

EnterEditGrid()

 

 

If blnEditGrid = True

Then

 

 

If Not MyBase.DataSource Is Nothing

Then

 

 

If Me.Rows.Count = 0

Then

 

 

If Me.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.Yes

Then

 

 

RaiseEvent

StNewRow()

 

 

If MyBase.DataSource.GetType() Is GetType(DataView)

Then

 

 

MyBase.DataSource.tables(0).rows.add(MyBase

.DataSource.Tables(0).newrow)

 

 

ElseIf MyBase.DataSource.GetType() Is GetType(DataTable)

Then

 

 

MyBase.DataSource.rows.add(MyBase

.DataSource.newrow)

 

 

Else

 

 

MyBase.DataSource.tables(0).rows.add(MyBase

.DataSource.Tables(0).newrow)

 

 

End

If

 

 

End

If

 

 

End

If

 

 

End

If

 

 

If IsNothing(MyBase.ActiveCell)

Then

 

 

If MyBase.Rows.Count > 0

Then

 

 

MyBase

.Rows(0).Cells(intFirstCol).Activate()

 

 

MyBase

.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)

 

 

MyBase.Rows(0).Cells(intFirstCol).Selected =

True

 

 

MyBase.Rows(0).Cells(intFirstCol).IsInEditMode =

True

 

 

End

If

 

 

Else

 

 

MyBase

.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)

 

 

MyBase.ActiveCell.Selected =

True

 

 

MyBase.ActiveCell.IsInEditMode =

True

 

 

End

If

 

 

End

If

 

 

End

Sub

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    I have a couple of suggestions...

    First, I would not use the GotFocus event. You should use Enter instead. Even Microsoft's documentation will advise you against using GotFocus since it's tied directly to the Windows messages and doesn't usually work well in DotNet programming.

    Second, this is probably just a timing problem. Instead of calling PerformAction(EnterEditMode) inside the event handler, use a BeginInvoke so that the grid completes whatever it is currently doing before the method gets called.

Children
No Data