I'm using WinForms Devexpress and bumped into the following task:
Somehow I need for DevExpress GridView to programmatically set data row selection checkbox to intermediate state (as the state of the top checkbox at the header at the picture below:
I'm wondering if it is possible or how to overcome the issue.
You should set the column editor's AllowGrayed property to true.
this.yourBooleanColumn.ColumnEdit = this.repositoryItemCheckEdit1;
this.repositoryItemCheckEdit1.AllowGrayed = true;
Related
I have a datagrid in wpf application in c#.
see this image:
I want to check all rows that their checkbox column is checked.
how can i do that?
I have a devexpress grid with a column that shows up as a checkbox. How can I disable this checkbox so that the user is not able to click on it, but it still displays a check or a blank box?
I suspect that column will be Boolean Column. Try setting Column.ColumnEdit to TextEdit It will display true or false instead showing CheckEdit.
By default Boolean column uses checkedit in devexpress grid that makes sense.
Note: I've not tested try it out
Using a DataGridView, how can I make a specific column uneditable while the grid view itself has "Allow editing" enabled?
Also, how can I execute an event when the selected index in a ComboBox in the DataGridView has changed? Here, ComboBox is a column type.
Another question is, how can I make the header title aligned to the center? I can't find the appropriate property.
You've got a few questions here.
(1) How can I make a specific column uneditable in DataGridView?
Set the ReadOnly flag on the particular column you want to make uneditable.
dataGridView.Columns["YourColumnName"].ReadOnly = true;
(2) How can I execute an event when the selected index on a ComboBox in the DataGridView changes?
If it's in your DataGridView, it's not a ComboBox; it's a DataGridViewComboBoxColumn. According to MSDN:
Unlike the ComboBox control, the DataGridViewComboBoxCell does not have SelectedIndex and SelectedValue properties. Instead, selecting a value from a drop-down list sets the cell Value property.
This one I'm not familiar with, as I've never tried it myself. It appears you want to subscribe to the EditingControlShowing event and then see if something like this works for you (with a little tweaking).
(3) How can I make the header title align in the center?
Set the HeaderCell.Style.Alignment
dataGridView.Columns["YourColumnName"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
I have a Datagridview with first column as checkbox.I have created the checkboxcolumn at design itself.While updating the gridview according to the entries from database, I have to check and uncheck the checkbox programatically not all at a time but only a specific row.Please tell me how can I update check boxes programmatically.
You can bind the data from database directly to checkbox column if it is bit type in DB.
Do something like this
(row.Cells[CheckBoxColumn.Index] as DataGridViewCheckBoxCell).value = false;
During bind data you need to check it manually if flag is true then set it checked otherwise unchecked as like
set checkbox1.checked=true or false
Check datagrid prerender event, get reference to the checkbox and set value accordingly.
At the time of databinding use this code
CheckBox chkbx= e.Item.FindControl("CheckBox1") as CheckBox;
then you can manipulate chkbx.Checked to true or false based on your values
and similarly it can be used for rest of the checkboxes buttons
I am currently using a datagridview in C# that is working correctly.
This datagridview has a checkbox field thats linked too a database, I am requiring all rows in the datagridview to be red until the checkbox is checked. Once the checkbox is checked the row will then turn green.
I am also requiring the checkbox field to be the only field in the datagrid that is not read only, but this isnt crucial at this stage. I hope you can offer me some suggestions.
Using visual studio 2010 in a windows forms application
Refer to CellContentClick event.
Read the cell value when user clicks it. If the checkbox is set then get the row index from event handler and write the following line in event handler.
datagrid.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green;