I created a custom control by and dragged a combobox on to the template
and then added the following code

Public Class dOOdadsOperandComboBox
Inherits System.Windows.Forms.ComboBox

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
operandComboBox.DataSource = operandComboBox.DataSource =
System.Enum.GetValues(GetType(Global.System.Windows.Forms.ColorDepth))
End Sub


End Class

Now on the form I added the control to it shows all the values listed
in the combobox and it works fine. But I added a button to test the
values and it gives me an error like the object doesn't exist.

MsgBox("Selected Value" &
Me.DOOdadsOperandComboBox1.SelectedValue.ToString)
MsgBox("Selected item " &
Me.DOOdadsOperandComboBox1.SelectedItem.ToString)

I don't even see the value that the combo box is displaying when
looking in the debug/locals window. I am expecting the msg to be
"Depth4bit" but I get an object reference not set to an instance of an
object exception.

Thanks

Re: Returning Values from a custom combobox by Brian

Brian
Thu Mar 02 11:01:18 CST 2006

What lacks a value? SelectedValue can be null? Try using a debugger to
examine the code as it runs. I suspect nothing is selected and that is
your problem.

BugSentry needs beta testers!
<a href="http://www.bugsentry.com">www.bugsentry.com</a>

*** Sent via Developersdex http://www.developersdex.com ***