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. Problem with dataGridComboBoxColumn object in VC# 2005

Problem with dataGridComboBoxColumn object in VC# 2005

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 Posts 2 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.
  • H Offline
    H Offline
    hdv212
    wrote on last edited by
    #1

    hi i was add dataGridComboBoxColumn in my datagridview and write this code to bind it to my column : this.personPropertiesTableAdapter.Fill(this.dataSet_AddressBook.PersonProperties); dataGridComboBoxColumn.DataSource = this.dataSet_AddressBook.PersonProperties; dataGridComboBoxColumn.ValueMember = "CategoryName"; but when i fill dataset, value don't show in dataGridComboBoxColumn and i must select dataGridComboBoxColumn and select that value from combo list,but i want when i fill dataset,value show on dataGridComboBoxColumn,but how to do ? thanks

    L 1 Reply Last reply
    0
    • H hdv212

      hi i was add dataGridComboBoxColumn in my datagridview and write this code to bind it to my column : this.personPropertiesTableAdapter.Fill(this.dataSet_AddressBook.PersonProperties); dataGridComboBoxColumn.DataSource = this.dataSet_AddressBook.PersonProperties; dataGridComboBoxColumn.ValueMember = "CategoryName"; but when i fill dataset, value don't show in dataGridComboBoxColumn and i must select dataGridComboBoxColumn and select that value from combo list,but i want when i fill dataset,value show on dataGridComboBoxColumn,but how to do ? thanks

      L Offline
      L Offline
      lainoo
      wrote on last edited by
      #2

      I design a class to DataGridViewComboBoxColumn and OTHERS when u want to bind data , u use : ClassLibrary_Pharm.Class_ComboBindData.u_ComboBindData(dataGridComboBoxColumn,"PersonProperties",SqlConnectionstring); follow is my project code, u can modify it using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Data; namespace ClassLibrary_Pharm { public static class Class_ComboBindData { public static bool u_ComboBindData(object combo, string sTopic) { return u_ComboBindData(combo, sTopic, null); } public static bool u_ComboBindData(object combo, string sTopic, EcareHis.C.Common.His_LogOn Logon) { bool blReturn = false; DataSet ds = null; switch (sTopic.ToLower().Trim()) { case "sex": ds = u_GetSexual(); break; case "stay": ds = u_GetStay(); break; case "readyflag": ds = u_GetConfect(); break; case "department": ds = u_GetDeptEmp(Logon,"epr"); break; case "code213": ds = u_GetCodeTable(Logon, "realhis","code213"); break; case "code211": ds = u_GetCodeTable(Logon, "realhis", "code211"); break; case "code212": ds = u_GetCodeTable(Logon, "realhis", "code212"); break; } if (ds == null) throw new Exception("not rows" + sTopic); if (ds.Tables["param"].Rows.Count < 1) throw new Exception("row count < 1" + sTopic); switch (combo.GetType().ToString()) { case "System.Windows.Forms.ComboBox": ((ComboBox)combo).DataSource = ds.Tables["param"]; ((ComboBox)combo).ValueMember = "value"; ((ComboBox)combo).DisplayMember = "mark"; break; case "System.Windows.Forms.DataGridViewComboBoxColumn": ((DataGridViewComboBoxColumn)combo).DataSource = ds.Tables["param"]; ((DataGridViewComboBoxColumn)combo).ValueMember = "value"; ((DataGridViewComboBoxColumn)combo).DisplayMember = "mark";

      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