 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 28th, 2006, 10:50 AM
|
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Two columns displayed in comboBox
Hi, everyone!
Does anybody know how to display two columns of a dataset on a ComboBox? As in MSAccess or Fox, with the wizards, you can define two fields from a table to be displayed on the combobox, and define the valuemember. I dont't have trouble with the valuemember, I just want to display two fields from my dataset onto de combobox. Can somebody help me, please?
MAKO - "El super simio"
__________________
MAKO - \"El super simio\"
|
|

April 28th, 2006, 10:53 AM
|
|
Authorized User
|
|
Join Date: Mar 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Using the dataset-designer, you can create an additional field in the dataset, which concatenates the two fields you want to display. Now, you can set this new field as your display member.
HTH
Sreeram
|
|

April 28th, 2006, 12:52 PM
|
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, Sreeram! That was very helpful.
On my squema genaration function, I add each column to the table in my dataset, I could add the field as you describe, but how would I get to fill that column with the data in field1 and field2? Perhaps an SQL SELECT Statement?
Please, just this once! Thank you.
MAKO - "El super simio"
|
|

April 28th, 2006, 03:03 PM
|
|
Authorized User
|
|
Join Date: Mar 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
MAKO, Glad to know that it helped.
Now, lemme try to make myself a li'l bit clearer.
In Visual Studio 2005, if you are using a typed dataset, you can goto the dataset-designer by dbl-clicking on the .xsd file. Once you find your table in that, you can right click on the table name and choose Add -> Column. Lets say the new column name is DisplayCol. Now, if you choose the properties of the column, there is an Expression property. Set that to field1 + ' ' + field2.
Thats it. Whenever you fill the table, this DisplayCol gets automatically populated with field1 + ' ' + field2. There are a lot of other expressions you can write. Check out http://msdn.microsoft.com/library/de...ssiontopic.asp
for more details.
If you still have more qns pls dont hesitate to contact.
Sreeram
|
|

April 29th, 2006, 12:30 PM
|
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have a doubt about dataAdapters in a try-catch block. Do they only fill one table in a dataset? From last year I've been struggling with a second and third table in a dataset not being fill with data. Now I had the same problem with a new application I'm practicing on, and I tried doing the try-catch block for eachone of the tables and finally worked. Sreeram, dude! Thanks a lot, you're AWSOME!!! IT WORKED!
"Till next time, take care of yourself...and eachother" Jerry Springer. ;)
MAKO - "El super simio"
|
|

April 29th, 2006, 02:45 PM
|
|
Authorized User
|
|
Join Date: Mar 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
As far as I know, whenever you create a dataset with the designer, it creates separate data adapters for EACH table in the dataset. Hence, you have to fill each separately.
Glad to know tht I cud be of help.
You take care too MAKO...
Sreeram
|
|

November 15th, 2011, 02:15 PM
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I know this thread is pretty much dead (nothing posted in years) but it helped answer a question for me so I thought maybe I could get another question under this subject answered.
I've concatenate the two values into the combobox... my question is, is there any way to make it so that the secondary data, or field 2, is all aligned equally so that i get:
asdf........1234
rewsd......3242
tre..........5432
instead of:
asdf..1234
rewsd..3243
tre..5432
The .. representing spaces
|
|
 |