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. Datagrid Combo box binding

Datagrid Combo box binding

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

    hi , i have this problem, i have a grid contains project combo box and projectStage combo,when i select the project from first combo it will filter the second combo values, i got it but when i m selecting the project for the next row it filter all second combo values even in the first row, here is my code private void FrmMain_Load(object sender, EventArgs e) { EMS.Timesheet timesheet = new WindowsApplication1.EMS.Timesheet(); dsInitialData = timesheet.GetInitialData(UserProfile.EmployeeId); bscProject.DataSource = dsInitialData.Tables["Projects"]; dgvTimeAttProject.DataSource = bscProject; dgvTimeAttProject.DisplayMember = "ProjectRef"; dgvTimeAttProject.ValueMember = "ProjectId"; bscStage.DataSource = dsInitialData.Tables["Stages"]; ; //bscStage.Filter = "ProjectTypeId=-1"; dgvTimeAttStage.DataSource = bscStage; dgvTimeAttStage.DisplayMember = "StageName"; dgvTimeAttStage.ValueMember = "ProjectStageId"; } private void dgvTimeAtt_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex == -1) return; if (dgvTimeAttProject.Index == e.ColumnIndex) { int ProjectId = (int)dgvTimeAtt.Rows[e.RowIndex].Cells[dgvTimeAttProject.Index].Value; int projectTypeId = GetProjectType(ProjectId); bscStage.Filter = "ProjectTypeId=" + projectTypeId.ToString(); bscActivity.Filter = "ProjectTypeId= " + projectTypeId.ToString(); //dgvTimeAttStage.DataSource = dsInitialData.Tables["Stages"].Select("ProjectTypeId=" + projectTypeId.ToString()); //dgvTimeAttActivity.DataSource = dsInitialData.Tables["Activities"].Select("ProjectTypeId= " + projectTypeId.ToString()); } } catch (Exception ex) { throw ex; } } so how can i overcome this problem?

    M 1 Reply Last reply
    0
    • M mrcooll

      hi , i have this problem, i have a grid contains project combo box and projectStage combo,when i select the project from first combo it will filter the second combo values, i got it but when i m selecting the project for the next row it filter all second combo values even in the first row, here is my code private void FrmMain_Load(object sender, EventArgs e) { EMS.Timesheet timesheet = new WindowsApplication1.EMS.Timesheet(); dsInitialData = timesheet.GetInitialData(UserProfile.EmployeeId); bscProject.DataSource = dsInitialData.Tables["Projects"]; dgvTimeAttProject.DataSource = bscProject; dgvTimeAttProject.DisplayMember = "ProjectRef"; dgvTimeAttProject.ValueMember = "ProjectId"; bscStage.DataSource = dsInitialData.Tables["Stages"]; ; //bscStage.Filter = "ProjectTypeId=-1"; dgvTimeAttStage.DataSource = bscStage; dgvTimeAttStage.DisplayMember = "StageName"; dgvTimeAttStage.ValueMember = "ProjectStageId"; } private void dgvTimeAtt_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex == -1) return; if (dgvTimeAttProject.Index == e.ColumnIndex) { int ProjectId = (int)dgvTimeAtt.Rows[e.RowIndex].Cells[dgvTimeAttProject.Index].Value; int projectTypeId = GetProjectType(ProjectId); bscStage.Filter = "ProjectTypeId=" + projectTypeId.ToString(); bscActivity.Filter = "ProjectTypeId= " + projectTypeId.ToString(); //dgvTimeAttStage.DataSource = dsInitialData.Tables["Stages"].Select("ProjectTypeId=" + projectTypeId.ToString()); //dgvTimeAttActivity.DataSource = dsInitialData.Tables["Activities"].Select("ProjectTypeId= " + projectTypeId.ToString()); } } catch (Exception ex) { throw ex; } } so how can i overcome this problem?

      M Offline
      M Offline
      mrcooll
      wrote on last edited by
      #2

      i will ask it in other words, if i have grid with tow DataGridViewComboBoxColumn first one for contries and second one for cities , when the user select a country the city combo will have the all cities in the country selected in first grid , i did it like that: bscCountries.datasource=GetAllCountries(); dgvCol_Countries.DataSource =bscCountries; dgvCol_Countries.DisplayMember ="Name"; dgvCol_Countries.ValueMember = "ID"; bscCities.datasource=GetAllCities); dgvCol_Cities.DataSource =bscCities; dgvCol_Cities.DisplayMember ="Name"; dgvCol_Cities.ValueMember = "ID"; private void dgvTimeAtt_CellValueChanged(object sender, DataGridViewCellEventArgs e) { bsc_Cities.filter="CountryId="+dgvCol_Countries.Rows[e.RowIndex].Cell[e.CellIndex].value; } that's work fine but , when i go to next row in the grid and select other country the selected city i choose is gone . How can i fix it?

      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