c# - Using DataGridViewComboBoxColumn for distinct options -
I am modifying the Winforms application in .NET 3.5.
I have a Datagrid view combobox column that is populated with some of the hard code options shown below.
// // dgvCol_PropName // this.dgvCol_PropName.DisplayStyle = System.Windows.Forms. DataGridViewComboBoxDisplayStyle.ComboBox; This.dgvCol_PropName.HeaderText = "Property Name"; This.dgvCol_PropName.Items.AddRange (new object [] {"Option1", "Option2", "Option3"}); This.dgvCol_PropName.Name = "dgvCol_PropName"; This.dgvCol_PropName.Width = 150; I want to separate the selection of these options do so once there is a place in the grid, it can not be selected again (the user must edit the current line or removed pay should
a quick way to do this?
I thought I'd share my final solution because it helps anyone else. My Selvalititing event handler is down :
/// & lt; summary & gt; /// bike handle verification event on the cell so only to those specific properties that /// & lt; / summary & gt; private void dg_FTPS_ExProps_CellValidating (object sender, DataGridViewCellValidatingEventArgs e) {var DataGrid = DataGridView Sender in; if (dataGrid! = Null) {// Only nominate that property if that property name is generated for the column string headerText = DataGrid.Column [e.ColumnIndex] Headertext; // Atlog validation if the cell property Name column is not in. // column instructions If the column order changes but equals //, there will be problems if there is a change in the column headers. (Pay your money and take a chance) if (Hedtekst. Aclols ( "property name") // if (e. Column index == 0) If the number of times the number of property attributes {// table Count = 0 ; Foreach (DataGridViewRow line dg_FTPS_ExProps.Rows) {if (row.Cells [e.ColumnIndex] .EditedFormattedValue.ToString (). Equals (e.FormattedValue) == true) {propertyCount ++;}} // Check if If tried to be implemented in multiple entreies (propertyCount> 1) {e.Cancel = true;}}}} To calculate the number of examples, L I liked to use INQ, but I am still learning what I know. Try to use this phenomenon in the body of the incident, if there is another line with only one price and if there is a check set
e. Cancel to true .
Comments
Post a Comment