Returning Values from a custom combobox

  • Thread starter phillip_putzback
  • Start date
P

phillip_putzback

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top