Apologies if this has already been asked but I cant see that it has been.
A Winforms DataGridView has an 'AllowUserToAddRows' property. Is there a way to ensure a new row is only added if certain conditions are met?
For example, I have a DataGridView with two columns, the first is a TextBox column, the second a ComboBox column. The 'AllowUserToAddRows' property is set to true.
However, I wish a new row to be added only if the user has entered a positive number in the TextBox column and made a selection from the ComboBox column. Currently a new row is added when anything is entered in the TextBox column, or if a selection is made in the ComboBox column.
Many thanks in advance
Related
I am trying to edit one column in a bound datagridview with a combobox (with fixed values YES or NO). I have the column type already set to DataGridViewAutoFilterTextBoxColumn (as I have the column filterable from the column header).
Is this at all possible?
I am sure I have seen a video tutorial somewhere where it is done by inserting a combobox inside the datagridview cell and somehow connecting the combobox value and the data source with each other.
Regards
I am having a datagrid which is scrollable, I have used templates to design it.
The columns are not autogenerated
I tried binding the data to datagrid with both ItemsSource and DataContext.
I have 2 columns which are editable to user out 10 columns.
When an user edits the data of rows and scrolls up/down the data edited moves into another row.
i.e. if i edit a row say row no. 1 and then scroll down to row no. 15 and edit it.
the row no. 1 data is lost and is seen in another row, say row no. 10.
Thnx in advance.
Check the Binding property of datagrid. make sure that the editable fied have binding set to
"Twoway".
Somehow my datagrid consider whole column as integer when each cell of that column has numbers. And it wont allow my to update cell with text value. I dont want to have any kind of validation on my grid. How do I disable validation from every cell.
here is image of what I have:
declare you clr properties as string.
I am using DataGrid on my Silverlight 4 application and there are two columns, one for question display and another for status.
After saving the answer of selected question I want to make visibilty collapsed of that row, how do I achieve that?
You will have to update your ItemsSource with a new list.
After you save, you simply remove that item from the list.
I want to allow the user to add a column and for that column to appear on screen. Is there a way to find which columns are currently on screen?
The property Columns of the Datagrid is an ObservableCollection<DataGridColumn>. You will find everithing you need there. If you want to know if any given column is visible, simply check MyDatagrid.Columns[i].Visibility
Adding columns in code is simple:
DataGridTemplateColumn col = new DataGridTemplateColumn();
MyDatagrid.Columns.Add(col);