|
Query |
Response |
|
1. First one is this. I have unbound checkbox column inside grid but unboundFields.Add only adds checkbox at the end of grid. How can I add checkbox on first column of grid?
this.dgv_RNTablica.TableDescriptor.UnboundFields.Add("CheckBoxValue"); this.dgv_RNTablica.TableDescriptor.Columns ["CheckBoxValue"].Appearance.AnyRecordFieldCell.CellType = "CheckBox"; |
By default, the unbound columns will be added at the end of the columns. To add the unbound fields to as first column, you can move the column manually by using the Move() method of VisibleColumns or Columns collection. Please refer to the below code,
Code example
//Suggestion 1
//To move the unbound field at the starting of the columns
int index =this.gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf("Select");
this.gridGroupingControl1.TableDescriptor.VisibleColumns.Move(index, 0);
//Suggestion 2
//To move the unbound field at the starting of the columns
int index =this.gridGroupingControl1.TableDescriptor.Columns.IndexOf("Select");
this.gridGroupingControl1.TableDescriptor.Columns.Move(index, 0);
|
|
2. Second question is related to first. My intentions are when i click checkbox in grid it selects whole row, i managed to archive this with this code:
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
Record currentRecord = style.TableCellIdentity.DisplayElement.GetRecord();
if (this.dgv_RNTablica.TableModel[e.Inner.RowIndex, e.Inner.ColIndex].Text == "")
currentRecord.SetSelected(true);
else
currentRecord.SetSelected(false);
This code selects row which is good and i can select as many rows i want but when I click on another checkbox it does select row but it also uncheckes checkbox previously checked, row stays selected but only checkbox currently clicked is checked rest of them just unchecked when ever i click on another row. |
By default, the unbound field’s values will not be updated to grid since, the column is added at run time and the data source of the grid does not contains the unbound column. This can be achieved by saving the cell value to the grid by customizing the SourceListListChanged and QueryValue events. We have already provided a KB to achieve this scenario. Please make use of the below KB link,
|
|
3. And little question how can i change color of selected rows, because in grid selected rows color is black but when i check checkbox currentRecord.SetSelected(true) makes selected row goes white almost invisible, can i change that color programmatically? |
In order to change the back color of selected records, the SelectionBackColor property can be used. Please make use of the below code,
Code example
//To set the selection back color
this.gridGroupingControl1.TableOptions.SelectionBackColor = Color.Red;
|
|
4. Last question :). How can i open field chooser on a button aoutside grid? is it even posible? right mouse click column is bad for me, would like to have button and when you click it field chooser opens like now. |
The FieldChooser can be shown on through a button click by using the Show() method of FieldChooser context menu. Please make use of the below code and sample,
Code example
private void fieldChooserBtn_Click(object sender, EventArgs e)
{
//To show the field chooser to the grid
fieldChooser.ContextMenu.Show(this.button1, newPoint(button1.Location.X, button1.Location.Y + button1.Height));
}
|