1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
bool noEvent=false;
// ***********************************************************************************
private void dgv1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (noEvent)
{
return;
}
ComboBox combo = e.Control as ComboBox;
if (combo != null)
{
// Remove an existing event-handler, if present, to avoid
// adding multiple handlers when the editing control is reused.
combo.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
// Add the event handler.
combo.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged);
}
}
// ***********************************************************************************
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
noEvent = true;
ComboBox combo = (ComboBox)sender;
if (combo.SelectedItem == null)
{
return;
}
DataRowView cRowV = (DataRowView)combo.SelectedItem;
DataRow cRow = cRowV.Row;
if (combo.DisplayMember == "Pays")
{
curPays = cRow["Pays"].ToString();
curPaysID = cRow["PaysID"].ToString();
string s = string.Format("PaysID='{0}'", curPaysID);
dvRegion.RowFilter = "";
dvRegion.RowFilter = s;
noEvent = false;
return;
}
if (combo.DisplayMember == "Region")
{
curReg = cRow["Region"].ToString();
return;
}
} |
Partager