Results 1 to 24 of 24

Thread: how to display two column value in combobox DisplayMember

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    how to display two column value in combobox DisplayMember

    hi i'm having hard time on how to display two column values in combox display member..like custID and custName...any sample code plz help

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    That's because it's not possible. If you want to display multiple columns then you have to derive your own class and add that functionality. There are various examples on the web. Search for multicolumn combobox or the like and you'll find them.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    Any sample code sir please!! So that i have a guide

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    I have no code examples. To find examples, I would have to search the web. You can do that just as easily as I can. They are out there because I've seen them before. Did you try at all?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    Yeah but it seem i havnt find the right way..just give me that link sir please

  6. #6
    Junior Member
    Join Date
    May 2007
    Posts
    23

    Re: how to display two column value in combobox DisplayMember


  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by crisjala View Post
    Yeah but it seem i havnt find the right way..just give me that link sir please
    What link? I already said that I didn't have any. All I can do is search, the same as you. Are you saying that you don't know how to search Google?

    http://lmgtfy.com/?q=multicolumn+combobox+.net

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    Tnx ive seen it but
    i dont know the firstep on how to do this

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    Did you download the source files? Did you download the demo project?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    Yes sir

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    Please give me the step of the process multicolumcombobox class...please

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by crisjala View Post
    Yes sir
    Then you already have everything you need. Import the class into your own project and away you go.

  13. #13
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: how to display two column value in combobox DisplayMember

    Can't you just combine your two columns in your sql and set it as the DisplayMember?

    Code:
    SELECT Column1 + ' ' + Column2 FROM table
    Regards,

    â„¢

    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    Re: how to display two column value in combobox DisplayMember

    TNX BUT THAT NOT WHAT I WANT TO DO
    THIS SOMETHING THAT I WANT TO TO DO IN THIS EXAMPLE http://www.codeproject.com/KB/combob...lumncombo.aspx BUT I DONT UNDERSTAND THE PROCESS OR STEP PROCESS

  15. #15
    New Member
    Join Date
    Apr 2011
    Posts
    1

    Re: how to display two column value in combobox DisplayMember

    @dee-u, That’s too cool man thanks that will help a lot on other projects as well. @crisjala, some times the best way to learn is not to be given the answer but close that will help you not only find the answer but strengthen you over all knowledge. but if you must here is my code based on the cluse dee-u sugested and it works perfect.
    Code:
    SELECT first_name1 + ' ' last_name2 AS full_name FROM table
    Code:
    me.combobox1.displaymember = full_name
    works like a charme
    thank dee-u

  16. #16
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by crisjala View Post
    TNX BUT THAT NOT WHAT I WANT TO DO
    THIS SOMETHING THAT I WANT TO TO DO IN THIS EXAMPLE http://www.codeproject.com/KB/combob...lumncombo.aspx BUT I DONT UNDERSTAND THE PROCESS OR STEP PROCESS
    YELLING will get you less help. Not more.

    Edit: I just realized Weax bumped a year old thread. I doubt the OP is following it anymore.
    Last edited by Lord_Rat; Apr 8th, 2011 at 11:34 AM.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  17. #17
    New Member
    Join Date
    May 2012
    Posts
    1

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by weax1569 View Post
    @dee-u, That’s too cool man thanks that will help a lot on other projects as well. @crisjala, some times the best way to learn is not to be given the answer but close that will help you not only find the answer but strengthen you over all knowledge. but if you must here is my code based on the cluse dee-u sugested and it works perfect.
    Code:
    SELECT first_name1 + ' ' last_name2 AS full_name FROM table
    Code:
    me.combobox1.displaymember = full_name
    works like a charme
    thank dee-u
    I've been hunting for a solution to accomplish this as well. Thanks guys!

  18. #18
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: how to display two column value in combobox DisplayMember

    i searched the internet, and got to this thread...... what is point of coming to vbforums if people tell you 'go google it'

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by schoemr View Post
    i searched the internet, and got to this thread...... what is point of coming to vbforums if people tell you 'go google it'
    Firstly, you shouldn't be posting on VBForums if you haven't already Googled it, which happens quite regularly. Secondly, I didn't just tell anyone to Google it. I told them what to Google and it was something they weren't aware of before, so the point to coming here would have been to find out what search terms to use. I know that those search terms do work to find relevant information because I've used them before myself but I'm not about to actually do a search for someone who is just as capable of doing it for themselves. If you asked someone on the street how to get to a place you didn't know, would you find it unacceptable for them to do anything but drive you there themselves or would you consider their giving you directions to be helpful? Maybe consider the fact that we all volunteer our time here and there are times that we consider it a waste of that time to reproduce something that we know is already out there and can be found in about 20 seconds. Does that answer your question?

    Just to confirm that things haven't changed in the last few years, I took the 20 seconds to search the web and, indeed, the relevant results are still out there and easy to find when the appropriate keywords are used. What's the point of there being a search engine if you don't bother to use it properly?

  20. #20
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: how to display two column value in combobox DisplayMember

    okay, you have wonderful google skills

    Maybe consider the fact that we all volunteer our time here and there are times that we consider it a waste of that time to reproduce something that we know is already out there and can be found in about 20 seconds.
    I agree, sometimes me too just need point in right direction.. But I think this person posted question was pleading for more detail as he was not understand....
    Last edited by schoemr; May 9th, 2016 at 06:34 AM.

  21. #21
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by schoemr View Post
    okay, you have wonderful google skills



    I agree, sometimes me too just need point in right direction.. But I think this person posted question was pleading for more detail as he was not understand....
    If it was something that I'd done before myself then I may have done more but it's not. I was not inclined to spend the time to work out how to do it myself first when there was so little evidence of effort on their own behalf. You may think that's harsh. That's your prerogative. I'm not paid to do this though so, if I choose to not help someone for some reason, that's my prerogative.

  22. #22
    New Member
    Join Date
    Aug 2016
    Posts
    3

    Re: how to display two column value in combobox DisplayMember

    Quote Originally Posted by jmcilhinney View Post
    If it was something that I'd done before myself then I may have done more but it's not. I was not inclined to spend the time to work out how to do it myself first when there was so little evidence of effort on their own behalf. You may think that's harsh. That's your prerogative. I'm not paid to do this though so, if I choose to not help someone for some reason, that's my prerogative.
    Checking the example above with sql statement, I'm using:
    Dim _sqlQuery As String = "SELECT fd_user_first_name + ' ' + fd_user_last_name AS full_name, fd_user_initials FROM " & TB_USERS

    then I call cboProjectManager.DisplayMember="full_name"

    and I get an error: Object reference not set to an instance of an object.

    I'm thinking I should declare full_name somehow. Any help is appreciated.

  23. #23
    New Member
    Join Date
    Aug 2016
    Posts
    3

    Re: how to display two column value in combobox DisplayMember

    never mind. I forgot to initialize some of the sql elements.

  24. #24
    New Member
    Join Date
    Aug 2016
    Posts
    3

    Re: how to display two column value in combobox DisplayMember

    works as intended. cool.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width