Cannot disable UltraGrid cells

2019-09-11 14:51发布

问题:

I have an UltraGrid in my project. Data can be entered into each cell, which is then saved to the database. I want to be able to disable all of the cells in the current row EXCEPT for one called Product_Code. Once data has been entered into the active row column (this is entered via a ValueList), I then want all of the other cells to become available for entering data into.

So far I have tried

If Me.ugProducts.ActiveRow.Cells("Product_Code").Value.ToString = "" Then
    Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.Disabled
Else
    Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.AllowEdit
End If

But to no success. When the project is built, all of the cells are immediately available to type into, despite no value having been entered.

Why is it not working? What is the best way to do this?

回答1:

I saw a previous comment on here that has since been deleted, for some reason... However, one solve you can try is:

  • In the form load; add in ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect - This will mean all of the cells are disabled, but you'll still be able to select the ValueList for Product_Code
  • Now, in the CellListSelect event of ugProducts, use the following code ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.Edit (After any validation checks or anything that you have in the method already, it will go in here somewhere, just keep trying things if you aren't too sure where)

Anyway, this should now let you fill them in as you wish.