473,326 Members | 2,126 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,326 software developers and data experts.

Problems adding dynamic combo boxes to windows forms

Hi all,

I'm sure I'm doing something silly here, but can't see it!

I'm creating a series of combo boxes on a Windows Form in VB.NET.

The lists of all of the comboboxes are identical and are held in a
table in a dataset and the number created is based on the number of
rows in a second table in the same dataset.

Code snippets

For i = 0 To mobjDataSet.Tables(mstrDriversTableName).Rows.Coun t - 1
..
..
..
'add the start positions
objCurrentComboBox = New ComboBox()
objPointsScheme.ListControlPopulateForms( _
objCurrentComboBox, _
mobjDataSet, _
"tblPointsScheme", _
False, _
True)

With objCurrentComboBox
.Left = 103
.Name = "cboStartPosition" & i.ToString
.Top = 35 + (i * 25)
.Width = 50
End With

Me.Controls.Add(objCurrentComboBox)
..
..
..
Next

Public Sub ListControlPopulateForms( _
ByRef objControl As System.Windows.Forms.ListControl, _
ByVal objDataSet As DataSet, _
ByVal strTableName As String, _
ByVal blnNoneEntryAdd As Boolean, _
ByVal blnSelectTextAdd As Boolean)
'populates the supplied listbox control with Points Schemes from
the table
Dim aryPointsSchemeDetails As ArrayList = New ArrayList()
Dim objPointsSchemeDetail As clsPointsSchemeDetail

'create an array of points scheme details
For Each objCurrentTableRow In
objDataSet.Tables(strTableName).Rows
objPointsSchemeDetail = New clsPointsSchemeDetail()
With objPointsSchemeDetail
.Id = objCurrentTableRow.Item("Id")
.intPoints = objCurrentTableRow.Item("intPoints")
.strPosition = objCurrentTableRow.Item("strPosition")
End With

aryPointsSchemeDetails.Add(objPointsSchemeDetail)
Next

'bind the array to the combo box and select the field to show the
position
With objControl
.DataSource = aryPointsSchemeDetails
.DisplayMember = "strPosition"
.ValueMember = "Id"
End With

'change the text of the listbox if necessary
If blnSelectTextAdd Then
objControl.Text = "Select"
End If

End Sub 'ListControlPopulateForms

Everything runs without an error, each combobox has the correct number
of entries in the list, but the text of each contains
'FormulaDe.Business.clsPointsSchemeDetail' which is the namespace/name
of the class, but is definitely not the contents of the strPosition
field.

The code is essentially copied from the ListControl.Datasource
Property entry in the .Net Framework SDK Documentation.

What am I doing wrong?

Cheers,

Duncan
Jul 21 '05 #1
0 1625

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

Similar topics

1
by: Daniel Hill | last post by:
OK, I have very, VERY basic background knowledge of VB6 and have now upgraded to VB.NET and now I'm struggling to bring up the forms I want. What I am looking to do is to have a click a command...
3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
5
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL...
3
by: simchajoy2000 | last post by:
Hi, I have been working with datagrids a lot in the past two weeks and I am running across a lot of problems. Maybe there is no way around these problems but I hope there are and someone out...
6
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
0
by: Duncan Spence | last post by:
Hi all, I'm sure I'm doing something silly here, but can't see it! I'm creating a series of combo boxes on a Windows Form in VB.NET. The lists of all of the comboboxes are identical and are...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
0
by: chixor1 | last post by:
Good afternoon All I have got over some hurdles on my current project and now I am stuck again. Im now having issues with writing the code that takes the calculations from my txt boxes and inserts...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.