473,387 Members | 1,619 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.

Binding Combobox in Datagrid to ArrayList

I have found a few samples of using a combobox in a Datagrid on the Web
(Windows Forms). While these examples work well for what they do, I need
more functionality, and I'd like some advice on the best way to implement it
(if it hasn't already been implemented, that is)...

Here's my situation:

-I have an ArrayList of Items that need to be bound to the combobox. The
ArrayList contains data like this:

1, Green
3, Yellow
7, Red

-The underlying Datagrid field should display the text value but the numeric
value will actually be written back to the database.

I've been trying to come up with the best way to do this, and so far my
ideas mostly entail adding a property to the class being used to implement
the combobox in datagrid, and setting it to the numeric value of the
selected combobox item. My other option was to load the lookup table values
into Hashtables of the form:

htColor ("Green") = 1
htColor ("Yellow") = 3
htColor ("Red") = 7

And then retrieve the Hashtable values before writing back to the database.
Because of design requirements, the Datagrid is *not* bound to the
Datasource - it is populated via a DataTable generated at run-time.

I just wanted to make sure I was on the right track here, if anyone knows of
this being done somewhere already (I'm sure I'm not the first person to
encounter this), or if I'm way off base with this one and obviously
insane...

Thanks.
Nov 21 '05 #1
0 1193

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

Similar topics

3
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add...
2
by: kids_pro | last post by:
I created a simple Person class as following: class Person{ private string fname; private string lname; public Person(string fname, string lname){ this.fname = fname; this.lname = lname; }
5
by: Alex Nitulescu | last post by:
Hi. I'm fighting the following code: __________________________________________________________________________ a. I have a class UserInfo.vb: <Serializable()> Public Class UserInfo Public...
3
by: Jim Bancroft | last post by:
Hi everyone, I'm binding an ArrayList to a DataGrid for the first time (I'm used to binding DataSets and DataTables) and I was wondering if I could somehow "name" the ArrayList, so that I can...
0
by: guy | last post by:
I have a winforms datagrid bound to an arraylist which works correctly, however if I add a row to the arraylist i cannot get the datagrid to display the updated data other than by:- clearing the...
5
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add...
16
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.