473,395 Members | 1,631 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,395 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 1378
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
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.