13 Replies - 4625 Views - Last Post: 17 December 2010 - 07:56 AM Rate Topic: -----

#1 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 05:48 AM

I am using a combobox.. and I want to display two columns combobox using the diplay member property...for example I have a table sam and it has two columns A and B .


following are details of column A

A

---

1

2

3



following are the details of column B


B

---

4

5

6




Now I want to display them into combobox as following...


1

2

3

4

5

6

Is This A Good Question/Topic? 0
  • +

Replies To: display two columns sequentiallly in combobox using display member pro

#2 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 05:51 AM

So you want to fetch all records from a column and another column and display them together?
Was This Post Helpful? 0
  • +
  • -

#3 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:11 AM

View PostSergio Tapia, on 17 December 2010 - 04:51 AM, said:

So you want to fetch all records from a column and another column and display them together?

ya...
in the order which I have previosly specified..
Was This Post Helpful? 0
  • +
  • -

#4 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:19 AM

foreach (var record in FetchFromColumnA() as string)
{
    comboBox1.Items.Add(record);
}

foreach (var record in FetchFromColumnB() as string)
{
    comboBox1.Items.Add(record);
}


You'll have to implement the Fetch methods but that's easy enough.

Can you tell us why you want to do something like this? Maybe we can suggest a better solution.
Was This Post Helpful? 0
  • +
  • -

#5 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:26 AM

View PostSergio Tapia, on 17 December 2010 - 05:19 AM, said:

foreach (var record in FetchFromColumnA() as string)
{
    comboBox1.Items.Add(record);
}

foreach (var record in FetchFromColumnB() as string)
{
    comboBox1.Items.Add(record);
}


You'll have to implement the Fetch methods but that's easy enough.

Can you tell us why you want to do something like this? Maybe we can suggest a better solution.



The purpose of doing so is that ,,, I want the user to select any record from both of these fields that are being displayed in combobox using displayMember property but I will get its userID (this is column name that I kept in valueMember field)

Any way thanks for the code but could you please give it in C#...because I don not know vb...
Was This Post Helpful? 0
  • +
  • -

#6 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:33 AM

From a UX standpoint, it'd be better to have two separate comboBoxes and properly label them. You'd still be giving the user the options to get the UserID however they want, but not confuse them.

ComboBox1
---------
sergio
lucas
george
boston
roslindale
austin



That's very confusing to look at and will probably be counter productive.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:37 AM

Quote

foreach (var record in FetchFromColumnA() as string)
{
    comboBox1.Items.Add(record);
}

foreach (var record in FetchFromColumnB() as string)
{
    comboBox1.Items.Add(record);
}


Any way thanks for the code but could you please give it in C#...because I don not know vb..


That IS C#! :rolleyes:

Copy, paste, repeat, eh?
Was This Post Helpful? 0
  • +
  • -

#8 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:47 AM

View PostSergio Tapia, on 17 December 2010 - 05:33 AM, said:

From a UX standpoint, it'd be better to have two separate comboBoxes and properly label them. You'd still be giving the user the options to get the UserID however they want, but not confuse them.

ComboBox1
---------
sergio
lucas
george
boston
roslindale
austin



sergio what about code in c# ??
I told you that I don't understand vb...
plz give me it in c#..
That's very confusing to look at and will probably be counter productive.

Was This Post Helpful? 0
  • +
  • -

#9 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 06:58 AM

You forgot to post code or text. You just quoted me.
Was This Post Helpful? 0
  • +
  • -

#10 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 07:05 AM

I am talking about the code you provided...
following code


foreach (var record in FetchFromColumnA() as string)
	{
	    comboBox1.Items.Add(record);
	}
	 
	foreach (var record in FetchFromColumnB() as string)
	{
	    comboBox1.Items.Add(record);
	}



Was This Post Helpful? 0
  • +
  • -

#11 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 07:18 AM

That's not visual basic code. That's C#, the code won't work because the Fetch methods aren't implemented. Are you just copy pasting the code?
Was This Post Helpful? 0
  • +
  • -

#12 samforever1989  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 53
  • Joined: 25-November 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 07:41 AM

View PostSergio Tapia, on 17 December 2010 - 06:18 AM, said:

That's not visual basic code. That's C#, the code won't work because the Fetch methods aren't implemented. Are you just copy pasting the code?


no it just seem to me...bcoz you used ...
"var" and "as" keywords....
Was This Post Helpful? 0
  • +
  • -

#13 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 07:55 AM

Read about the var keyword here:
http://stackoverflow...ar-keyword-in-c
Was This Post Helpful? 0
  • +
  • -

#14 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4462
  • View blog
  • Posts: 7,776
  • Joined: 08-June 10

Re: display two columns sequentiallly in combobox using display member pro

Posted 17 December 2010 - 07:56 AM

var
as
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1