AllenJ
9 years ago
If you use something like below, it doesn't work too well.
That's because the .Enabled property returns an iGBool value, which is, in my opinion, non intuitive.

iGBool.True = 0
iGBool.False = 1
iGBool.NotSet = 2

If ig.Cells(ig.CurRow.Index, colidx).Enabled Then
   ig.SetCurCell(ig.CurRow.Index, colidx)
   ig.RequestEditCurCell()
   Exit While
 End If

So if the the cell is Enabled, the code ig.Cells(ig.CurRow.Index, colidx).Enabled returns 0, which the if statement interprets as False, and if the cell is Disabled (or NotSet) , it returns either 1 or 2, which the if statement interprets as true.

Perhaps the values should be more like

iGBool.False = 0
iGBool.True = 1
iGBool.NotSet = 2

The way around it to explicitly compare the value to the iGBool setting:

If ig.Cells(ig.CurRow.Index, colidx).Enabled <> iGBool.False Then
    ig.SetCurCell(ig.CurRow.Index, colidx)
    ig.RequestEditCurCell()
   Exit While
End If
Igor/10Tec
8 years ago
You can have such a problem only in VB.NET, which allows implicit data type conversions by default. Your If statement would not compile at all if you used the 'Option Strict On' setting.

Even if we redefined iGBool.False as 0 and iGBool.True as 1, we still would have the same problem with the iGBool.NotSet value equals 2. When 'Option Strict' is 'Off', iGBool.NotSet is always interpreted as True.

Note that iGBool.NotSet is the default value for iGCell.Enabled, and in the general case the effective Enabled status of the cell is determined by its parents like the column cell style, the grid settings, etc. So I think in your case you really need to check the iGBool value explicitly like you do it in this statement:

If ig.Cells(ig.CurRow.Index, colidx).Enabled <> iGBool.False Then

In fact, all developers using other .NET languages like C# use this explicit form of comparison. You are free to do it only in VB due to the feature I started this post with.

*****

A side note. iGrid.NET was developed in the early times of .NET, when only the version 1.x of this framework was available. Perhaps, a much better choice for the data type of the iGCell.Enabled property would be the Nullable Boolean type, but nullable types appeared only in .NET 2.0. We did not change the iGBool type to Nullable(Of Boolean) because of backward compatibility and because we have this NotSet value in other enumerations of iGrid. It's a part of the iGrid ideolology, when you can inherit a value from a parent with this special NotSet value.