473,394 Members | 1,567 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,394 software developers and data experts.

ComboxBox Selection

If I have a table with say Id (key) and Desc, and a ComboBox

box.DataSource = table;
box.ValueMember = table.IDColumn.ColumnName;
box.DisplayMember = table.DescColumn.ColumnName;

and the box has Sorted = true (ie sort on Desc) then when an item is selected,
how do I tie the selected item back to the table ? That is, is there anything in
the selected item that contains the table row or number ?
Mar 27 '06 #1
3 2061
On Tue, 28 Mar 2006 08:00:25 +1000, Ian Semmel
<is***********@NOKUNKrocketcomp.com.au> wrote:
If I have a table with say Id (key) and Desc, and a ComboBox

box.DataSource = table;
box.ValueMember = table.IDColumn.ColumnName;
box.DisplayMember = table.DescColumn.ColumnName;

and the box has Sorted = true (ie sort on Desc) then when an item is selected,
how do I tie the selected item back to the table ? That is, is there anything in
the selected item that contains the table row or number ?

Isn't the IDColumn the row ID of your table? If it's not use the row ID of the
table instead.

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Mar 28 '06 #2
I worked it out,

In box_OnSelectedIndexChanged, :-

DataRowView dv = (DataRowView) box.SelectedItem;

currentID = (int) dv.Row.ItemArray [ table.IDColumn.Ordinal ];

Otis Mukinfus wrote:
On Tue, 28 Mar 2006 08:00:25 +1000, Ian Semmel
<is***********@NOKUNKrocketcomp.com.au> wrote:

If I have a table with say Id (key) and Desc, and a ComboBox

box.DataSource = table;
box.ValueMember = table.IDColumn.ColumnName;
box.DisplayMember = table.DescColumn.ColumnName;

and the box has Sorted = true (ie sort on Desc) then when an item is selected,
how do I tie the selected item back to the table ? That is, is there anything in
the selected item that contains the table row or number ?


Isn't the IDColumn the row ID of your table? If it's not use the row ID of the
table instead.

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com

Mar 28 '06 #3
On Tue, 28 Mar 2006 16:14:13 +1000, Ian Semmel
<is***********@NOKUNKrocketcomp.com.au> wrote:
I worked it out,

In box_OnSelectedIndexChanged, :-

DataRowView dv = (DataRowView) box.SelectedItem;

currentID = (int) dv.Row.ItemArray [ table.IDColumn.Ordinal ];

Otis Mukinfus wrote:
On Tue, 28 Mar 2006 08:00:25 +1000, Ian Semmel
<is***********@NOKUNKrocketcomp.com.au> wrote:

If I have a table with say Id (key) and Desc, and a ComboBox

box.DataSource = table;
box.ValueMember = table.IDColumn.ColumnName;
box.DisplayMember = table.DescColumn.ColumnName;

and the box has Sorted = true (ie sort on Desc) then when an item is selected,
how do I tie the selected item back to the table ? That is, is there anything in
the selected item that contains the table row or number ?


Isn't the IDColumn the row ID of your table? If it's not use the row ID of the
table instead.

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com

Good job, Ian!
Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Mar 28 '06 #4

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

Similar topics

1
by: Martin Karlsson | last post by:
Hi guys, Does anyone know how I can restore a selection created with createRange()? The problem is that I have a function that opens a new window with window.open() which of course makes the...
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
1
by: bob | last post by:
I asked a question yesterday about how I would parse a Word document using functions in some Interop.Word COM. Some told me to run a macro in Word to see how it works. Most of the code was......
5
by: STeve | last post by:
Hey guys, I currently have a 100 page word document filled with various "articles". These articles are delimited by the Style of the text (IE. Heading 1 for the various titles) These articles...
0
by: ROO | last post by:
Hi Everyone, I have a database table that have 4 field( C1, C2, M1, M2) on my form i have two combo box ComboC and ComboM C1 C2 M1 M2 1 ...
1
by: 4Ankit | last post by:
Hey guys i am having some trouble with nesting one selection structure within another selection structure. At the moment i am unclear what selection structures are and just need a simple example of...
5
by: Jure Bogataj | last post by:
Hi all! I have a problem (performance issue) with listview. I have implemented an ItemSelectionChange on my listview and put some code in it (I build some toolbar based on selection and update...
2
by: vanditnagar | last post by:
Hi, I am facing the difficulty in the selecting a text on the browser . And highlighting the text. I am using the window.getSelection() to get the object and after...
3
by: Venturini | last post by:
I am trying to put together a web page where the customer makes choices of products and is then given a total. I am extremely new to Javascript and have managed to get as far as I have from web...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...

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.