Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Returning Values from a custom combobox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
phillip_putzback@insightbb.com - 01 Mar 2006 15:32 GMT
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
Brian - 02 Mar 2006 17:01 GMT
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>

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.