简体   繁体   中英

Datagrid Selection Changed Method

Currently I am trying to write a method to let user click on any datagrid cell or row in the datagrid view and after clicking information from datagrid view appers in the various textboxes / combo boxes. The thing is after clicking on the item it just doesn't work. Last time I when I wrote something else it was datagrid multiselect option which set to ture and caused problems, this time I have no idea what I did wrong. Method itself:

private void dataGridView3_SelectionChanged(object sender, EventArgs e)
{
   foreach (DataGridViewRow row in this.dataGridView3.SelectedRows)
   {
      Group selectedGrp = row.DataBoundItem as Group;
      if (selectedGrp != null)
      {
          this.textGrpID.Text = selectedGrp.GrpID;
          this.textGrpName.Text = selectedGrp.GrpName;
          this.comboBoxGrp.SelectedValue = selectedStd.StdGrp;
      }
   }
}

You want to show the textboxs for enter the the free text while clicking the row on datagrid. do u use the Edit template for showing the textbox and dropdown?

Why use the SelectionChanged event then? You didn't mention anything about changing selections... you said the user would click on a cell to see this information... so why not handle the Click event instead?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM