title: set value in combobox inside datagridview
body: <p>I Have Datagridview with combobox inside and i can't set the index in code
  I read <a href="https://stackoverflow.com/questions/5778621/set-selected-items-for-datagridview-combobox-failed">this</a> and <a href="https://stackoverflow.com/questions/5976511/how-to-set-value-to-datagridviewcombobox-column">this</a> - both not work.</p>
  
  <p>here is my code:</p>
  
  <pre><code>  dgShuffle.DataSource = dtCards;
    DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
    cmb.HeaderText = "Select Data";
    cmb.Name = "cmb";
    cmb.MaxDropDownItems = 2;
    cmb.Items.Add("real");
    cmb.Items.Add("sham");
  
    dgShuffle.Columns.Add(cmb);
    for (int i = 0; i &lt; dgShuffle.RowCount; i++)
    {
         (dgShuffle.Rows[i].Cells[6] as DataGridViewComboBoxCell).Value = "real";
          // dgShuffle.Rows[i].Cells[6].Value = "real";
    }
  </code></pre>
  
  <p>To set by code i mean : programmatically (depend on the value in datatble).
  I Dont Get error at all. the value simply not display in the combobox</p>
  
  <p>I checked the index of the combobox and this is correct , below the output from my immediate window:</p>
  
  <blockquote>
    <p>?dgShuffle.Rows[i].Cells[6]</p>
    
    <p>{DataGridViewComboBoxCell { ColumnIndex=6, RowIndex=0 }}    [System.Windows.Forms.DataGridViewComboBoxCell]: {DataGridViewComboBoxCell { ColumnIndex=6, RowIndex=0 }}
        base: {DataGridViewComboBoxCell { ColumnIndex=6, RowIndex=0 }}
        AccessibilityObject: {System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject}
        ColumnIndex: 6
        ContentBounds: {X = 0 Y = 12 Width = 0 Height = 0}
        ContextMenuStrip: null
        DefaultNewRowValue: null
        Displayed: false
        EditedFormattedValue: ""
        EditType: {Name = "DataGridViewComboBoxEditingControl" FullName = "System.Windows.Forms.DataGridViewComboBoxEditingControl"}
        ErrorIconBounds: {X = 0 Y = 0 Width = 0 Height = 0}
        ErrorText: ""
        FormattedValue: ""
        FormattedValueType: {Name = "String" FullName = "System.String"}
        Frozen: false
        HasStyle: false
        InheritedState: Resizable | ResizableSet | Visible
        InheritedStyle: {DataGridViewCellStyle { BackColor=Color [Window], ForeColor=Color [ControlText], SelectionBackColor=Color [Highlight], SelectionForeColor=Color [HighlightText], Font=[Font: Name=Microsoft Sans Serif, Size=7.8, Units=3, GdiCharSet=177, GdiVerticalFont=False], WrapMode=False, Alignment=MiddleLeft }}
        IsInEditMode: false
        OwningColumn: {DataGridViewComboBoxColumn { Name=cmb, Index=6 }}
        OwningRow: {DataGridViewRow { Index=0 }}
        PreferredSize: {Width = 43 Height = 26}
        ReadOnly: false
        Resizable: true
        RowIndex: 0
        Selected: false
        Size: {Width = 100 Height = 24}
        Style: {DataGridViewCellStyle { }}
        Tag: null
        ToolTipText: ""
        Value: null
        ValueType: {Name = "Object" FullName = "System.Object"}
        Visible: true</p>
  </blockquote>
  
  <h1>Next try :</h1>
  
  <ol>
  <li>I create a new winforms project</li>
  <li>Drag datagridview to the default form (from the toolbox)</li>
  <li><p>Copy this code to  Form1_Load :</p>
  
  <pre><code>    DataTable dtCards;
      dtCards = new DataTable();
      dtCards.Columns.Add("printedString");
      dtCards.Rows.Add("1");
      dtCards.Rows.Add("2");
      dtCards.Rows.Add("3");
      dtCards.Rows.Add("4");
      dataGridView1.DataSource = dtCards;
  
      DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
      cmb.HeaderText = "Select Data";
      cmb.Name = "cmb";
      cmb.MaxDropDownItems = 2;
      cmb.Items.Add("real");
      cmb.Items.Add("sham");
  
      dataGridView1.Columns.Add(cmb);
      for (int i = 0; i &lt; dataGridView1.RowCount; i++)
      {
          (dataGridView1.Rows[i].Cells[6] as DataGridViewComboBoxCell).Value = "real";
          // dgShuffle.Rows[i].Cells[6].Value = "real";
      }
  </code></pre></li>
  </ol>
  
  <p>What am i missing???</p>