乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      DataGridView內包含ComboBox列 實現(xiàn)選定ComboBox的項數(shù)據(jù)的聯(lián)動.

       順溜的書架 2014-10-25
      2007-12-05 11:18 2437人閱讀 評論(1) 收藏 舉報

      首先要綁定 ComboBox 然后綁定DataGridView

                  

                   DataSet dsProp = new DataSet();
                   DataSet dsCond 
      = new DataSet();
                   DataSet dsCond1 
      = new DataSet();
                   DataSet dsCond2 
      = new DataSet();
                  
      try
                  
      {
                      dsProp 
      = App.DbService.GetStandardControlProp(intPrjCode, intStationId, intModuleId, intPointId);
                      dsCond 
      = App.DbService.GetStandardControlCond(intPrjCode,intStationId, intModuleId,1);
                      dsCond1 
      = App.DbService.GetStandardControlCond(intPrjCode, intStationId, intModuleId, 2);
                      dsCond2 
      = App.DbService.GetStandardControlCond(intPrjCode, intStationId, intModuleId, 3);
                      dsStationInfo 
      = App.DbService.getStationNameDs(intPrjCode);
                      
                  }

                  
      catch (Exception ex)
                  
      {
                      MessageBox.Show(ex.Message, 
      "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Error);
                      
      return;
                  }

                  
      if (dsProp == null || dsCond==null)
                  
      {
                      MessageBox.Show(
      "數(shù)據(jù)加載失敗!");
                      
      return;
                  }

                              
                  DataRow drNew 
      = dsStationInfo.Tables[0].NewRow();
                  drNew[
      "stationid"= System.DBNull.Value;
                  drNew[
      "stationnm"= System.DBNull.Value;
                  dsStationInfo.Tables[
      0].Rows.InsertAt(drNew, 0);

                  StationID.DataSource 
      = dsStationInfo.Tables[0];
                  StationID.DisplayMember 
      = "STATIONNM";
                  StationID.ValueMember 
      = "STATIONID";
                  MODULEID.DataSource 
      = dsCond.Tables[0];
                  MODULEID.DisplayMember 
      = "MODULEID";
                  MODULEID.ValueMember 
      = "MODULEID";
                  POINTNM.DataSource 
      = dsCond.Tables[0];
                  POINTNM.DisplayMember 
      = "POINTNAME";
                  POINTNM.ValueMember 
      = "POINTID";

                  StationID2.DataSource 
      = dsStationInfo.Tables[0];
                  StationID2.DisplayMember 
      = "STATIONNM";
                  StationID2.ValueMember 
      = "STATIONID";
                  MODULENM2.DataSource 
      = dsCond1.Tables[0];
                  MODULENM2.DisplayMember 
      = "MODULEID";
                  MODULENM2.ValueMember 
      = "MODULEID";
                  POINTNM2.DataSource 
      = dsCond1.Tables[0];
                  POINTNM2.DisplayMember 
      = "POINTNAME";
                  POINTNM2.ValueMember 
      = "POINTID";

                  StationID3.DataSource 
      = dsStationInfo.Tables[0];
                  StationID3.DisplayMember 
      = "STATIONNM";
                  StationID3.ValueMember 
      = "STATIONID";
                  MODULENM3.DataSource 
      = dsCond2.Tables[0];
                  MODULENM3.DisplayMember 
      = "MODULEID";
                  MODULENM3.ValueMember 
      = "MODULEID";
                  POINTNM3.DataSource 
      = dsCond2.Tables[0];
                  POINTNM3.DisplayMember 
      = "POINTNAME";
                  POINTNM3.ValueMember 
      = "POINTID";
                  
                  dgvList.DataSource 
      = InitDT(dsCond.Tables[0].Copy(), 100);
                  dgvList2.DataSource 
      = InitDT(dsCond1.Tables[0].Copy(), 70);
                  dgvList3.DataSource 
      = InitDT(dsCond2.Tables[0].Copy(), 71);

      注意設定ComboBox的屬性:DataPropertyName ,然后調用CellValueChanged事件,此事件主要完成在選定ComboBox時重新綁定要改變的ComboBox.

       private void dgvList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
              
      {
                  dgvCellAutoSetValue(e, dgvList);
              }

       

       

      private void dgvCellAutoSetValue(DataGridViewCellEventArgs e, DataGridView dgv)
              
      {

                  
      if (e.ColumnIndex == 1)
                  
      {
                      
      if (e.RowIndex > -1)
                      
      {
                          
      if (dgv.Rows[e.RowIndex].Cells[1].Value == System.DBNull.Value)
                          
      {
                              
      return;
                          }

                          DataGridViewComboBoxCell cell 
      = (DataGridViewComboBoxCell)dgv.Rows[e.RowIndex].Cells[2];
                          
      try
                          
      {
                              DataTable DtModule 
      = App.DbService.GetModuleIDInfo(intPrjCode, Convert.ToInt16(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)).Tables[0];
                              
      if (DtModule.Rows.Count > 0)
                              
      {
                                  cell.DataSource 
      = DtModule;
                                  
                                  cell.DisplayMember 
      = "MODULEID";
                                  cell.ValueMember 
      = "MODULEID";

                                  
      if (cell.Items.Count > 0)
                                  
      {
                                      cell.Value 
      = ((DataRowView)cell.Items[0]).Row[cell.ValueMember];
                                  }

                              }

                          }

                          
      catch (Exception ex)
                          
      {
                              MessageBox.Show(ex.Message);
                          }

                      }

                  }

                  
      else if (e.ColumnIndex == 2)
                  
      {
                      
      if (e.RowIndex > -1)
                      
      {
                          
      if (dgv.Rows[e.RowIndex].Cells[2].Value == System.DBNull.Value || dgv.Rows[e.RowIndex].Cells[1].Value==DBNull.Value)
                          
      {
                              
      return;
                          }

                          
      int stationid = Convert.ToInt16(dgv.Rows[e.RowIndex].Cells[1].Value);
                          
      int moduleid = Convert.ToInt16(dgv.Rows[e.RowIndex].Cells[2].Value);
                          DataGridViewComboBoxCell cell 
      = (DataGridViewComboBoxCell)dgv.Rows[e.RowIndex].Cells[3];
                          
      try
                          
      {
                              DataTable DtPoint 
      = App.DbService.GetPointInfo(intPrjCode, stationid, moduleid).Tables[0];
                              
      if (DtPoint.Rows.Count > 0)
                              
      {
                                  cell.DataSource 
      = DtPoint;
                                  cell.DisplayMember 
      = "POINTNAME";
                                  cell.ValueMember 
      = "POINTID";
                                  
      if (cell.Items.Count > 0)
                                  
      {
                                      cell.Value 
      = ((DataRowView)cell.Items[0]).Row[cell.ValueMember];
                                  }

                              }

                          }

                          
      catch (Exception ex)
                          
      {
                              MessageBox.Show(ex.Message);
                          }

                      }

                  }

              }

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多