2012-03-29 24 views
1

こんにちはプログラマ、 は実際に私はDataGridViewの中DataGridViewComboBoxCellを持っていると私はCellContentClickイベントが発生したときの条件がtrueの場合DataGridViewComboBox値を変更する必要があります。 マイコードはこのように書きます:どのように手動でCellContentClickイベントでDataGridviewComboBoxCell値を選択するには?

private void gridviewholiday_CellContentClick_1(object sender, DataGridViewCellEventArgs e) 
    { 
     int row = e.RowIndex; 
     int colo = e.ColumnIndex; 


     /*=============== To Show The Details =====================*/ 

     if (e.ColumnIndex == 4) 
     { 
      if (Convert.ToBoolean(gridviewholiday.Rows[e.RowIndex].Cells[0].Value)) 
      { 
       if (Type == "CUS") 
       { 
        Type = test.colType; 
        if (Type == "NO") 
        { 


         ComboBox combo = (ComboBox)sender; 
         combo.SelectedIndex = 0; 

        } 
       } 
    } 

しかし、コンボボックスにDataGridViewのをキャストしながら、それはエラーが発生します。

私を助けてください。

答えて

1

こんにちはフレンズ!

私は私の答えを持って、私は手動でDataGridviewComboBoxCellを選択します。

private void gridviewholiday_CellContentClick_1(object sender, DataGridViewCellEventArgs e) 
{ 
    int row = e.RowIndex; 
    int colo = e.ColumnIndex; 


    /*=============== To Show The Details =====================*/ 

    if (e.ColumnIndex == 4) 
    { 
     if (Convert.ToBoolean(gridviewholiday.Rows[e.RowIndex].Cells[0].Value)) 
     { 
      if (Type == "CUS") 
      { 
       Type = test.colType; 
       if (Type == "NO") 
       { 
        /*===== set the selected value of comboboxCellItems ==========*/ 

         gridviewholiday.Rows[e.RowIndex].Cells["colType"].Value="ALL" 



       } 
      } 
} 

最後に私の問題は解決しました。

関連する問題