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
1187
Change selected cell when user clicks on cell not editable.
posted

 I have a grid with several columns, only the two right most columns are editable.  When a user clicks on a cell that isn't editable, I want focus to go to the first cell on that row that is editable.  Why doesn't the following code work?  The selected cell stays on the cell clicked on.

     Private Sub grdOptions_BeforeSelectChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeSelectChangeEventArgs) Handles grdOptions.BeforeSelectChange
        If e.NewSelections.Cells.Count = 0 Then Exit Sub
        If e.NewSelections.Cells(0).Column.CellActivation = Activation.AllowEdit Then Exit Sub
        e.Cancel = True
        For Each c As UltraGridCell In e.NewSelections.Cells(0).Row.Cells
            If c.Column.CellActivation = Activation.AllowEdit Then
                LogCommon.WriteDebug(New String() {"grdOptions_BeforeSelectChange()", "Select Changed To", c.Column.Header.Caption})
                c.Selected = True
                Exit For
            End If
        Next
    End Sub
 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    How are you disabled editing in the other columns? From the code here, it seems like you are probably setting CellActivation on the columns, but what are you setting it to? If it's Disabled, then I expect BeforeSelectChange will not even fire when you click on one of those cells. 

    Also, it seems to me like you should be concerned with the active cell here, not selected. Active and selected are two totally different things and it's important to understand the different. A grid can have multiple selected cells - this just means that the cell is highlighted to the user. There can only be only active cell - this is the cell that is being edited. 

    But again, if the CellActivation is disabled, the BeforeCellActivate event won't even fire when you click on that cell.

Children