Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to display two column value in combobox DisplayMember

how to display two column value in combobox DisplayMember

Scheduled Pinned Locked Moved C#
helptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crisjala
    wrote on last edited by
    #1

    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

    P N 2 Replies Last reply
    0
    • C crisjala

      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

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      Hi, Not sure how you would do it using the .NET toolkit (ComboBox), but if you make use of the control toolkit from DevExpress (which has 60 free controls), you can make use of their LookUpEdit control, which has this type of functionality. Here is an example if you are interested: LookUpEdit Control[^] Kind regards,

      1 Reply Last reply
      0
      • C crisjala

        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

        N Offline
        N Offline
        nagendrathecoder
        wrote on last edited by
        #3

        Its quite simple actually :

        //Create a DataTable for binding to combobox
        DataTable dt = new DataTable();
        dt.Columns.Add("ID");
        dt.Columns.Add("Name");

        //Read values from dbase and fill it in datatable
        //I am taking DataReader here

        while(reader.Read())
        {
        DataRow dr = dt.NewRow();
        dr["ID"] = reader.GetValue(0);
        dr["Name"] = reader.GetValue(0) + reader.GetValue(1);
        dt.Rows.Add(dr);
        }

        combobox.DataSource = dt;
        combobox.DataBind();

        Hope this helps you. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups