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

DataSets: processing data

Yet another newbie question. I have a dataset of an table: I need to
list the values in the Windows Forms application.

A ComboBox, more specifically. The table does not contain any directly
user-readable data: how would I "customize" what the ComboBox's
SelectedText says to a custom format, which could contain data from the
table's fields?

Thanks
Aug 13 '08 #1
4 1374
Sorry, by "SelectedText" I meant DisplayMember.

Sweetiecakes wrote:
Yet another newbie question. I have a dataset of an table: I need to
list the values in the Windows Forms application.

A ComboBox, more specifically. The table does not contain any directly
user-readable data: how would I "customize" what the ComboBox's
SelectedText says to a custom format, which could contain data from the
table's fields?

Thanks
Aug 13 '08 #2
On Aug 13, 6:06*pm, Sweetiecakes <x...@x.comwrote:
Yet another newbie question. I have a dataset of an table: I need to
list the values in the Windows Forms application.

A ComboBox, more specifically. The table does not contain any directly
user-readable data: how would I "customize" what the ComboBox's
SelectedText says to a custom format, which could contain data from the
table's fields?
You should bind the DataGridViewComboBoxColumn to a data source (via
its DataSource property), which contains mappings between display
text, and actual values. For example, assuming you have integer values
stored in the database:

Array mapping = new[] {
new { Text = "Red", Value = 1 },
new { Text = "Green", Value = 2 },
new { Text = "Blue", Value = 3 }
} ;

column.DataSource = mapping;
column.DisplayMember = "Text";
column.ValueMember = "Value";

Now the actual value read from or written into the datasource will be
whatever is in the Value property, but the text displayed in the cell
will be taken from the corresponding Text property.
Aug 13 '08 #3
Hi. The dataset was filled with an SQLDataAdapter. From what I can see,
this is not possible to do in this case.

Pavel Minaev wrote:
On Aug 13, 6:06 pm, Sweetiecakes <x...@x.comwrote:
>Yet another newbie question. I have a dataset of an table: I need to
list the values in the Windows Forms application.

A ComboBox, more specifically. The table does not contain any directly
user-readable data: how would I "customize" what the ComboBox's
SelectedText says to a custom format, which could contain data from the
table's fields?

You should bind the DataGridViewComboBoxColumn to a data source (via
its DataSource property), which contains mappings between display
text, and actual values. For example, assuming you have integer values
stored in the database:

Array mapping = new[] {
new { Text = "Red", Value = 1 },
new { Text = "Green", Value = 2 },
new { Text = "Blue", Value = 3 }
} ;

column.DataSource = mapping;
column.DisplayMember = "Text";
column.ValueMember = "Value";

Now the actual value read from or written into the datasource will be
whatever is in the Value property, but the text displayed in the cell
will be taken from the corresponding Text property.
Aug 13 '08 #4
On Aug 13, 6:38*pm, Sweetiecakes <x...@x.comwrote:
Hi. The dataset was filled with an SQLDataAdapter. From what I can see,
this is not possible to do in this case.
It doesn't matter where the dataset was filled from (and indeed,
whether the data source is even a dataset). Note that I'm talking
about binding the _combobox column_ to an array, not binding the
entire DataGridView to something. You can very well do both things at
the same time.
Aug 14 '08 #5

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

Similar topics

7
by: Ryan | last post by:
I'm in the process of learning more about building my ASP.NET website to use my SQL datastore and am a bit confused about how ADO.NET works with ASP.NET. This Microsoft article implies that using...
5
by: sql_er | last post by:
Guys, I have an XML file which is 233MB in size. It was created by loading 6 tables from an sql server database into a dataset object and then writing out the contents from this dataset into an...
4
by: Burt | last post by:
I'm working on a Windows app that pulls data from SQL Server, displays it on various forms and grids, and allows the user to update, insert, delete data. Some but not much business logic, just...
1
by: Mark Baldwin | last post by:
Steven Thanks for your reply, however the typed datasets are defined in the web service and there seems to way to open the partial class code window - double clicking on the design surface does...
9
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.