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

problem with AddRange and Combobox

Sam
Hi,
I don't know how to specify the display and value field for a combobox
when using AddRange to fill the combo.
Here is what I have so far:
-A function to build an array of object :
Dim returnData() As Object
Do While myReader.Read()
ReDim Preserve returnData(count)
Dim currentData As New DataRecord
currentData.Display = myReader.GetValue(0).ToString
If ValueField Then
currentData.Value = myReader.GetValue(1)
End If
returnData(count) = currentData
count += 1
Loop
Return returnData
______________________________*___________________
-A function that calls the above and fills my combo
cboHeaderType.Items.AddRange(m*_queries.GetGetIden tTypes())
______________________________*___________________ _
The problem is that apparentely the display and value specified above
don't work and no value is selected in my combobox.
Can you help
Thx
Reply

Nov 21 '05 #1
5 2983
Sam,

You cannot add a value to a value in the combobox.

It has to be a property from an Icollection implementing collection.

I hope this helps,

Cor
Nov 21 '05 #2
Sam
Cor,
You cannot add a value to a value in the combobox. What do you mean ?
It has to be a property from an Icollection implementing collection


Could you give me a short example please ?

Thx

Nov 21 '05 #3
Sam

Roughly written here

\\\
dim dt as new datatable
dt.columns("display")
dt.columns("value")
dt.loadrow(object() {sam},true)
mycombobox.datasource = dt
mycombobox.displaymember = "display"
mycombobox.valuemember = "value"
///

Or any other icollection implementing collection.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #4
Sam
Thanks. This does not use AddRange. My function returns an array of
object as mentionned above. Is it not possible ?

Nov 21 '05 #5
Sam,

For that are in fact as well a lot of methods, to get the value is a little
bit harder than with a datasource.

An old sample Herfried showed a (long) while ago

http://www.google.de/groups?selm=e9Z...TNGP09.phx.gbl

I hope this helps,

Cor
Nov 21 '05 #6

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

Similar topics

3
by: Billy Jacobs | last post by:
I have created a DataGridColumnDatePicker Component so that I can put a datetimepicker control in my datagrid. It almost works. When I put my mouse in the cell it changes to a datetimepicker...
5
by: Richard Muller | last post by:
Hi All, As I recall from Java Swing, I could assign the widths of columns to something like a list control proportionally rather than absolutely. That is, essentially I could assign "weights"...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
3
by: Don | last post by:
Me.cbxLocation.Items.AddRange(New Object() {"Item0", "Item1", "Item2", "Item3"}) Me.cbxLocation.DropDownWidth = 114 Me.cbxLocation.Location = New System.Drawing.Point(72, 16) Me.cbxLocation.Name =...
2
by: David Morris | last post by:
Hi I want to add multiple items (about 20) to a checked list box control at run time, but do not know how to use the AddRange method of the Items collection. Currently, I am using the Add method,...
2
by: Fred Flintstone | last post by:
This is driving me crazy. I've put together a perfect, easy example of the problem. What I'm doing is creating a custom control, prepopulated with 4 items when dropped on a form: - Create a new...
0
by: Amiram Korach | last post by:
When you create a MDI form, you can attach a main menu to the parent and to the child. When a child form is active, its menu is merged with the parent menu. The problem is: when the forms are...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.