D
Diego Deberdt
I'm trying to show the ReportsTo field of the Employees table in the
Northwind database in a databound ComboBox. This works fine, except for the
case where ReportsTo is NULL. When ReportsTo is NULL the ComboBox should
show an empty string, or whatever, but it shows the first item in the list.
I have tried catching the Format event to detect NULL values and translate
them into something else, and the event actually gets called and I can
detect the DBNull values, but two things are odd. The field e.DesiredType is
always System.Object, while I'm expecting it to be of type Integer. The
second thing is that setting e.Value does not seem to have any effect.
Public Sub NULLToZero(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs)
If e.Value Is DBNull.Value Then
e.Value = 0
End If
End Sub
Northwind database in a databound ComboBox. This works fine, except for the
case where ReportsTo is NULL. When ReportsTo is NULL the ComboBox should
show an empty string, or whatever, but it shows the first item in the list.
I have tried catching the Format event to detect NULL values and translate
them into something else, and the event actually gets called and I can
detect the DBNull values, but two things are odd. The field e.DesiredType is
always System.Object, while I'm expecting it to be of type Integer. The
second thing is that setting e.Value does not seem to have any effect.
Public Sub NULLToZero(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs)
If e.Value Is DBNull.Value Then
e.Value = 0
End If
End Sub