473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.Diagnostics.DebuggerNonUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

End If

MyBase.Dispose(disposing)

End Sub

Friend WithEvents ComboBox1 As WindowsApplication1.StringWithIntegerComboBox

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'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 InitializeComponent()

Me.ComboBox1 = New WindowsApplication1.StringWithIntegerComboBox

Me.SuspendLayout()

'

'ComboBox1

'

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

Me.ComboBox1.Name = "ComboBox1"

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

Me.ComboBox1.TabIndex = 0

'

'Form1

'

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

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.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 StringWithIntegerComboBox

Inherits System.Windows.Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMember = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteger("One", 1))

myList.Add(New StringWithInteger("Two", 2))

myList.Add(New StringWithInteger("Three", 3))

End Sub

Public myList As List(Of StringWithInteger) = New List(Of StringWithInteger)

End Class

Public Class StringWithInteger

Private mInteger As Integer

Private mString As String

Private mToStringDisplaysInteger As Boolean = False

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

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteger

Clone = New StringWithInteger(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDisplaysInteger 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 ToStringDisplaysSingle() As Boolean

Get

ToStringDisplaysSingle = mToStringDisplaysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDisplaysInteger = 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 1485
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*************@TK2MSFTNGP05.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.Diagnostics.DebuggerNonUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

End If

MyBase.Dispose(disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplication1.StringWithIntegerComboBox

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'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 InitializeComponent()

Me.ComboBox1 = New WindowsApplication1.StringWithIntegerComboBox

Me.SuspendLayout()

'

'ComboBox1

'

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

Me.ComboBox1.Name = "ComboBox1"

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

Me.ComboBox1.TabIndex = 0

'

'Form1

'

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

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.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 StringWithIntegerComboBox

Inherits System.Windows.Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMember = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteger("One", 1))

myList.Add(New StringWithInteger("Two", 2))

myList.Add(New StringWithInteger("Three", 3))

End Sub

Public myList As List(Of StringWithInteger) = New List(Of
StringWithInteger)

End Class

Public Class StringWithInteger

Private mInteger As Integer

Private mString As String

Private mToStringDisplaysInteger As Boolean = False

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

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteger

Clone = New StringWithInteger(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDisplaysInteger 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 ToStringDisplaysSingle() As Boolean

Get

ToStringDisplaysSingle = mToStringDisplaysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDisplaysInteger = 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*************@TK2MSFTNGP05.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.Diagnostics.DebuggerNonUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

End If

MyBase.Dispose(disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplication1.StringWithIntegerComboBox

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'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 InitializeComponent()

Me.ComboBox1 = New WindowsApplication1.StringWithIntegerComboBox

Me.SuspendLayout()

'

'ComboBox1

'

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

Me.ComboBox1.Name = "ComboBox1"

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

Me.ComboBox1.TabIndex = 0

'

'Form1

'

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

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.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 StringWithIntegerComboBox

Inherits System.Windows.Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMember = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteger("One", 1))

myList.Add(New StringWithInteger("Two", 2))

myList.Add(New StringWithInteger("Three", 3))

End Sub

Public myList As List(Of StringWithInteger) = New List(Of
StringWithInteger)

End Class

Public Class StringWithInteger

Private mInteger As Integer

Private mString As String

Private mToStringDisplaysInteger As Boolean = False

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

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteger

Clone = New StringWithInteger(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDisplaysInteger 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 ToStringDisplaysSingle() As Boolean

Get

ToStringDisplaysSingle = mToStringDisplaysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDisplaysInteger = 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**********************************@microsof t.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*************@TK2MSFTNGP05.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.Diagnostics.DebuggerNonUserCode()_

Protected Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Dispose()

End If

MyBase.Dispose(disposing)

End Sub

Friend WithEvents ComboBox1 As
WindowsApplication1.StringWithIntegerComboBox

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'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 InitializeComponent()

Me.ComboBox1 = New WindowsApplication1.StringWithIntegerComboBox

Me.SuspendLayout()

'

'ComboBox1

'

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

Me.ComboBox1.Name = "ComboBox1"

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

Me.ComboBox1.TabIndex = 0

'

'Form1

'

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

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.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 StringWithIntegerComboBox

Inherits System.Windows.Forms.ComboBox

Public Sub New()

MyBase.New()

Me.DataSource = myList

Me.DisplayMember = "Str"

Me.ValueMember = "Value"

myList.Add(New StringWithInteger("One", 1))

myList.Add(New StringWithInteger("Two", 2))

myList.Add(New StringWithInteger("Three", 3))

End Sub

Public myList As List(Of StringWithInteger) = New List(Of
StringWithInteger)

End Class

Public Class StringWithInteger

Private mInteger As Integer

Private mString As String

Private mToStringDisplaysInteger As Boolean = False

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

mString = str

mInteger = value

End Sub

Public Function Clone() As StringWithInteger

Clone = New StringWithInteger(mString, mInteger)

End Function

Public Overrides Function ToString() As String

If mToStringDisplaysInteger 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 ToStringDisplaysSingle() As Boolean

Get

ToStringDisplaysSingle = mToStringDisplaysInteger

End Get

Set(ByVal displayInteger As Boolean)

mToStringDisplaysInteger = 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**********************************@microsof t.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****************@TK2MSFTNGP04.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**********************************@microsof t.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
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...
1
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...
1
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...
0
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...
0
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...
1
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
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...
2
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.