davesyd1970
2011-03-14T06:15:56Z
Hi

I am trying to prevent the user from being able to click on or select certain cells in a grid.

I have tried finding certain cancel options in the available events, and also trying to use the setfocus command.

Nothing seems to get me there.

I am using the OCX is Excel VBA


Thanks
Igor/10Tec
2011-03-14T09:33:05Z
Read the following post in this iGrid ActiveX section:

Lock Cells 
davesyd1970
2011-03-14T09:55:52Z
I'd like to suggest a method which I found which is different from that in the 'lock cells' and involves two steps.
In theory we should see the selection flash but in reality there is nothing at all.

STEP 1 - store in variable the row and col of the cell which was just UNSELECTED (bSelected = False)

Private Sub igrdSubCategory_CellSelectionChange(ByVal lRow As Long, ByVal lCol As Long, ByVal bSelected As Boolean)

    If bSelected = False Then
        m_lLastCol = lCol
        m_lLastRow = lRow
    End If
    
End Sub

STEP 2 - Verify on the cell just received selection whether it is valid. If invalid selection then move the selection to the previously selected cell

Private Sub igrdSubCategory_CurCellChange(ByVal lRow As Long, ByVal lCol As Long)

If bFXIsSelectableItem(igrdSubCategory, lRow, lCol) = True Then
    'Do nothing
Else
    Call igrdSubCategory.SetCurCell(m_lLastCol, m_lLastRow)
End If

End Sub
Igor/10Tec
2011-03-14T10:43:55Z
Yes, a good and smart idea if you need just to prevent some cells from being selected (i.e. you can 'stay' in the previous cell if it isn't allowed).
Igor/10Tec
2011-04-16T05:12:08Z
To you and all customers. Many developers asked us about this functionality, and taking into account all these requests we implemented the CellSelectable property which can be used to implement this task easily. It is already available in a new version of iGrid, v4.7, we released yesterday. Now if you need to prevent a cell from being selected, you just set CellSelectable to False for it.