473,778 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Designer shows combobox but run time does not

I tried to use a datasource with a combobox and it didn't work completely so
I build a small test that was much more straight forward then the app.

The test was to see if the combobox dropdown list displayed the correct
data.

However, although the designer shows the combobox the combobox does not
show at runtime.

If you would be so kind as to cut the code below and paste it into a form
maybe you can easily see why the combobox does not display.

Thanks



Public Class Form1

Inherits System.Windows. Forms.Form

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

Friend WithEvents ComboBox1 As WindowsApplicat ion1.StringWith IntegerComboBox

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Private Sub InitializeCompo nent()

Me.ComboBox1 = New WindowsApplicat ion1.StringWith IntegerComboBox

Me.SuspendLayou t()

'

'ComboBox1

'

Me.ComboBox1.Lo cation = New System.Drawing. Point(136, 139)

Me.ComboBox1.Na me = "ComboBox1"

Me.ComboBox1.Si ze = New System.Drawing. Size(235, 21)

Me.ComboBox1.Ta bIndex = 0

'

'Form1

'

Me.AutoScaleDim ensions = New System.Drawing. SizeF(6.0!, 13.0!)

Me.AutoScaleMod e = System.Windows. Forms.AutoScale Mode.Font

Me.ClientSize = New System.Drawing. Size(572, 341)

Me.Controls.Add (Me.ComboBox1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout (False)

End Sub

End Class

Public Class StringWithInteg erComboBox

Inherits System.Windows. Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMembe r = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteg er("One", 1))

myList.Add(New StringWithInteg er("Two", 2))

myList.Add(New StringWithInteg er("Three", 3))

End Sub

Public myList As List(Of StringWithInteg er) = New List(Of StringWithInteg er)

End Class

Public Class StringWithInteg er

Private mInteger As Integer

Private mString As String

Private mToStringDispla ysInteger As Boolean = False

Public Sub New(ByVal str As String, ByVal value As Integer)

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteg er

Clone = New StringWithInteg er(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDispla ysInteger Then

ToString = CStr(mInteger)

Else

ToString = mString

End If

End Function

Public Property Str() As String

Get

Str = mString

End Get

Set(ByVal text As String)

mString = text

End Set

End Property

Public Property ToStringDisplay sSingle() As Boolean

Get

ToStringDisplay sSingle = mToStringDispla ysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDispla ysInteger = displayInteger

End Set

End Property

Public Property Value() As Integer

Get

Value = mInteger

End Get

Set(ByVal numb As Integer)

mInteger = numb

End Set

End Property

End Class
Feb 19 '07 #1
5 1506
Sorry don't have access to VS but it seems that you are adding the entries
after you bind the list to the combobox. Try it the other way or refresh
the combobox after you add the entries. I don't think that adding will
automatically cause the control to know there are entries. When you bound
the list was empty.

Lloyd Sheen
" active" <ac********** @a-znet.comwrote in message
news:ef******** *****@TK2MSFTNG P05.phx.gbl...
>I tried to use a datasource with a combobox and it didn't work completely
so I build a small test that was much more straight forward then the app.

The test was to see if the combobox dropdown list displayed the correct
data.

However, although the designer shows the combobox the combobox does not
show at runtime.

If you would be so kind as to cut the code below and paste it into a form
maybe you can easily see why the combobox does not display.

Thanks



Public Class Form1

Inherits System.Windows. Forms.Form

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplicat ion1.StringWith IntegerComboBox

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Private Sub InitializeCompo nent()

Me.ComboBox1 = New WindowsApplicat ion1.StringWith IntegerComboBox

Me.SuspendLayou t()

'

'ComboBox1

'

Me.ComboBox1.Lo cation = New System.Drawing. Point(136, 139)

Me.ComboBox1.Na me = "ComboBox1"

Me.ComboBox1.Si ze = New System.Drawing. Size(235, 21)

Me.ComboBox1.Ta bIndex = 0

'

'Form1

'

Me.AutoScaleDim ensions = New System.Drawing. SizeF(6.0!, 13.0!)

Me.AutoScaleMod e = System.Windows. Forms.AutoScale Mode.Font

Me.ClientSize = New System.Drawing. Size(572, 341)

Me.Controls.Add (Me.ComboBox1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout (False)

End Sub

End Class

Public Class StringWithInteg erComboBox

Inherits System.Windows. Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMembe r = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteg er("One", 1))

myList.Add(New StringWithInteg er("Two", 2))

myList.Add(New StringWithInteg er("Three", 3))

End Sub

Public myList As List(Of StringWithInteg er) = New List(Of
StringWithInteg er)

End Class

Public Class StringWithInteg er

Private mInteger As Integer

Private mString As String

Private mToStringDispla ysInteger As Boolean = False

Public Sub New(ByVal str As String, ByVal value As Integer)

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteg er

Clone = New StringWithInteg er(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDispla ysInteger Then

ToString = CStr(mInteger)

Else

ToString = mString

End If

End Function

Public Property Str() As String

Get

Str = mString

End Get

Set(ByVal text As String)

mString = text

End Set

End Property

Public Property ToStringDisplay sSingle() As Boolean

Get

ToStringDisplay sSingle = mToStringDispla ysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDispla ysInteger = displayInteger

End Set

End Property

Public Property Value() As Integer

Get

Value = mInteger

End Get

Set(ByVal numb As Integer)

mInteger = numb

End Set

End Property

End Class

Feb 19 '07 #2
Sorry, I lost the New sub when I copied.
Works Ok with it.
" active" <ac********** @a-znet.comwrote in message
news:ef******** *****@TK2MSFTNG P05.phx.gbl...
>I tried to use a datasource with a combobox and it didn't work completely
so I build a small test that was much more straight forward then the app.

The test was to see if the combobox dropdown list displayed the correct
data.

However, although the designer shows the combobox the combobox does not
show at runtime.

If you would be so kind as to cut the code below and paste it into a form
maybe you can easily see why the combobox does not display.

Thanks



Public Class Form1

Inherits System.Windows. Forms.Form

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplicat ion1.StringWith IntegerComboBox

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Private Sub InitializeCompo nent()

Me.ComboBox1 = New WindowsApplicat ion1.StringWith IntegerComboBox

Me.SuspendLayou t()

'

'ComboBox1

'

Me.ComboBox1.Lo cation = New System.Drawing. Point(136, 139)

Me.ComboBox1.Na me = "ComboBox1"

Me.ComboBox1.Si ze = New System.Drawing. Size(235, 21)

Me.ComboBox1.Ta bIndex = 0

'

'Form1

'

Me.AutoScaleDim ensions = New System.Drawing. SizeF(6.0!, 13.0!)

Me.AutoScaleMod e = System.Windows. Forms.AutoScale Mode.Font

Me.ClientSize = New System.Drawing. Size(572, 341)

Me.Controls.Add (Me.ComboBox1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout (False)

End Sub

End Class

Public Class StringWithInteg erComboBox

Inherits System.Windows. Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMembe r = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteg er("One", 1))

myList.Add(New StringWithInteg er("Two", 2))

myList.Add(New StringWithInteg er("Three", 3))

End Sub

Public myList As List(Of StringWithInteg er) = New List(Of
StringWithInteg er)

End Class

Public Class StringWithInteg er

Private mInteger As Integer

Private mString As String

Private mToStringDispla ysInteger As Boolean = False

Public Sub New(ByVal str As String, ByVal value As Integer)

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteg er

Clone = New StringWithInteg er(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDispla ysInteger Then

ToString = CStr(mInteger)

Else

ToString = mString

End If

End Function

Public Property Str() As String

Get

Str = mString

End Get

Set(ByVal text As String)

mString = text

End Set

End Property

Public Property ToStringDisplay sSingle() As Boolean

Get

ToStringDisplay sSingle = mToStringDispla ysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDispla ysInteger = displayInteger

End Set

End Property

Public Property Value() As Integer

Get

Value = mInteger

End Get

Set(ByVal numb As Integer)

mInteger = numb

End Set

End Property

End Class


Feb 19 '07 #3
This test case works OK, but my app doesn't.

I'll try what you suggested on the app.

Thanks

"Lloyd Sheen" <a@b.cwrote in message
news:5E******** *************** ***********@mic rosoft.com...
Sorry don't have access to VS but it seems that you are adding the entries
after you bind the list to the combobox. Try it the other way or refresh
the combobox after you add the entries. I don't think that adding will
automatically cause the control to know there are entries. When you bound
the list was empty.

Lloyd Sheen
" active" <ac********** @a-znet.comwrote in message
news:ef******** *****@TK2MSFTNG P05.phx.gbl...
>>I tried to use a datasource with a combobox and it didn't work completely
so I build a small test that was much more straight forward then the app.

The test was to see if the combobox dropdown list displayed the correct
data.

However, although the designer shows the combobox the combobox does not
show at runtime.

If you would be so kind as to cut the code below and paste it into a form
maybe you can easily see why the combobox does not display.

Thanks



Public Class Form1

Inherits System.Windows. Forms.Form

'Form overrides dispose to clean up the component list.

<System.Diagno stics.DebuggerN onUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Dis pose()

End If

MyBase.Dispose (disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplica tion1.StringWit hIntegerComboBo x

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Private Sub InitializeCompo nent()

Me.ComboBox1 = New WindowsApplicat ion1.StringWith IntegerComboBox

Me.SuspendLayo ut()

'

'ComboBox1

'

Me.ComboBox1.L ocation = New System.Drawing. Point(136, 139)

Me.ComboBox1.N ame = "ComboBox1"

Me.ComboBox1.S ize = New System.Drawing. Size(235, 21)

Me.ComboBox1.T abIndex = 0

'

'Form1

'

Me.AutoScaleDi mensions = New System.Drawing. SizeF(6.0!, 13.0!)

Me.AutoScaleMo de = System.Windows. Forms.AutoScale Mode.Font

Me.ClientSiz e = New System.Drawing. Size(572, 341)

Me.Controls.Ad d(Me.ComboBox1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayou t(False)

End Sub

End Class

Public Class StringWithInteg erComboBox

Inherits System.Windows. Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSourc e = myList

Me.DisplayMemb er = "Str"

Me.ValueMemb er = "Value"

myList.Add(N ew StringWithInteg er("One", 1))

myList.Add(N ew StringWithInteg er("Two", 2))

myList.Add(N ew StringWithInteg er("Three", 3))

End Sub

Public myList As List(Of StringWithInteg er) = New List(Of
StringWithInte ger)

End Class

Public Class StringWithInteg er

Private mInteger As Integer

Private mString As String

Private mToStringDispla ysInteger As Boolean = False

Public Sub New(ByVal str As String, ByVal value As Integer)

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteg er

Clone = New StringWithInteg er(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDispla ysInteger Then

ToString = CStr(mInteger)

Else

ToString = mString

End If

End Function

Public Property Str() As String

Get

Str = mString

End Get

Set(ByVal text As String)

mString = text

End Set

End Property

Public Property ToStringDisplay sSingle() As Boolean

Get

ToStringDispla ysSingle = mToStringDispla ysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDispl aysInteger = displayInteger

End Set

End Property

Public Property Value() As Integer

Get

Value = mInteger

End Get

Set(ByVal numb As Integer)

mInteger = numb

End Set

End Property

End Class


Feb 19 '07 #4
You got that right. If I delay Binding until after I've filled the list it
displays OK.

Refreshing the combobox didn't work.

After I've changed data in the list I need a way to "unbind" the list and
"rebind" it.

How do you think I should do that?

Thanks for the help
"Lloyd Sheen" <a@b.cwrote in message
news:5E******** *************** ***********@mic rosoft.com...
Sorry don't have access to VS but it seems that you are adding the entries
after you bind the list to the combobox. Try it the other way or refresh
the combobox after you add the entries. I don't think that adding will
automatically cause the control to know there are entries. When you bound
the list was empty.

Lloyd Sheen

Feb 19 '07 #5
Ok , still don't have access to code but if the refresh doesn't work then
you just need to rebind the datasource. When you bind it will refresh the
contents according to the new content. Just resetting the datasource
property should do it.

Lloyd
" active" <ac********** @a-znet.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
You got that right. If I delay Binding until after I've filled the list it
displays OK.

Refreshing the combobox didn't work.

After I've changed data in the list I need a way to "unbind" the list and
"rebind" it.

How do you think I should do that?

Thanks for the help
"Lloyd Sheen" <a@b.cwrote in message
news:5E******** *************** ***********@mic rosoft.com...
>Sorry don't have access to VS but it seems that you are adding the
entries after you bind the list to the combobox. Try it the other way or
refresh the combobox after you add the entries. I don't think that
adding will automatically cause the control to know there are entries.
When you bound the list was empty.

Lloyd Sheen

Feb 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
12504
by: Martin Schulze | last post by:
Hello, i tried to compose myself a custom usercontrol which is derieved from System.Windows.Forms.UserControl. It contains 2 comboboxes and one textbox (which are also custom controls, but directly derived from the .net classes ComboBox and TextBox) I did the custom control in the visual studio .net designer in which i
1
6396
by: Rachel Suddeth | last post by:
When I put a ComboBox on a form, I can enter strings through the designer to fill Items collections. I have put a ComboBox in a UserControl, and exposed the the Items collections with the same type... public class ControlWithComboBox : MyControls.BaseControl, IDataEntryControl { ... protected System.Windows.Forms.ComboBox comboBox; ... public ComboBox.ObjectCollection Items
1
1930
by: TXIce | last post by:
Not sure if this is the right group...but I'm going to try here anyways. I have a problem that is driving me absolutely crazy. I'm starting a new ASP.Net web application and I'm trying to add an image web control. No matter what I do...when I point the imageurl to the picture I want to display...the only thing that shows in the VS.Net designer is a small little box with a red "X" in it. If I compile the project and ftp it up to my web...
0
1424
by: Ken Dopierala Jr. | last post by:
Hi, When I change properties through the property window on my custom control and then move focus from that property cell VS.Net runs the GetDesignTimeHtml() method on my designer. When I implement a UITypeEditor, change the values, then close the editor nothing happens until I switch the HTML view (which shows the changes) and then switch back to design view which then shows the new stuff. I can get to my component through the...
0
982
by: Bob | last post by:
I'm trying to get a combox in a datagridview to be displaying diffrent filtered data each time it lands on a row. I thought of adding the follwing code as a test. Later I would have verified that the code only executed when entering the cell of the combobox column just so that we would not get fills when entering every cell in a row. In any case I wrote. Private Sub TblCompanyDataGridView_CellEnter(ByVal sender As Object, ByVal e As...
1
1278
by: mehdi | last post by:
Hi folks, Consider a custom class that's being derived from the TextBox and has got the following propert: public override string Text { get { return "get"; } set {base.Text = "set";} }
2
1905
by: PGP | last post by:
I recently derived from a ComboBox to make a countries combo and included it in couple of forms. The derived combo box loads an xml list of countries and uses the DataSource and DisplayMember properties to point to the appropriate node in xml. All this is done in the derived combo's constructor. This causes forms designer to load slower as it seems to initialize these derived combos with the country list. If i did not care about the...
2
2607
by: AAaron123 | last post by:
Useing vs2008 I created a new web site. I opened .aspx file to get the tab titled Default.aspx, which has the views: Source, Split and Design I draged a couple of components on to the .aspx (design) surface. I right-clicked default.aspx and selected View Component Designer to get a tab titled Default.aspx.vb
2
2023
by: steve | last post by:
I have the very simple derived class below but when I drag the class from the toolbox on to one of my UserControls VS designer extracts the information and puts it into its resource database for the control. Then when I build and run the control I find that the LineWidthComboBox quite often appears with 2 copies of the item list. I.e. 8 entries instead of 4. This usually only happens after I have run the application and can happen even...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8957
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.