We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Questions on cells'' edit mode and change of the selection color of a whole row.

1)For grid control/data bound grid, How can I make the grid never have edit mode for the cell of certain columns while the whole row always being selected? E.g. there're 6 columns in a grid, and column 4, 5, 6 are read only and not editable, thus the cells of these column should not have the edit mode.

2)For these 2 types of grid, How can I change the select back color and select fore color when the whole row is selected?
Once I try to remove Alphablend from AllowSelection list(Because it can not provide me the conventional selection effect: blue background and white text ), it turns out the selection back color become black?


2 Replies

FE Feng March 29, 2011 01:25 AM UTC

How to deactivate a cell's editing mode of a DataBoundGrid and always make the whole row being selected instead? and how to change the selection color of this row?
Many thanks.



RA Rajasekar Syncfusion Team April 1, 2011 11:46 AM UTC

Hi Feng,

Thanks for using Syncfusion products.

Regarding Non-Editable Cell:

In GridDataControl,
you can make particular column as non-editable by setting ReadOnly property as True in the respective VisibleColumn of the DataGrid like shown below:

Code Snippet[XAML]



- - -
- - -

- - -
- - -




In GridControl, you can make particular column or cell or row as non-editable by setting ReadOnly property as True in the QueryCellInfo event of the datagrid like shown below:

Code Snippet[C#]

this.grid.QueryCellInfo += new GridQueryCellInfoEventHandler(grid_QueryCellInfo);

void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.Cell.ColumnIndex > 3)
{
e.Style.ReadOnly = true;
}

e.Style.CellValue = string.Format("Row{0}/Col{1}",e.Style.RowIndex,e.Cell.ColumnIndex);
}

Regarding Background and Foreground Color for Selected Rows:

In GridDataControl, you can achieve your requirement like shown below:

Code Snippet[C#]

this.dataGrid.HighlightSelectionBackground = Brushes.Blue;
this.dataGrid.HighlightSelectionForeground = Brushes.White;

In GridControl, you can achieve your requirement like shown below:

Code Snippet[C#]

this.grid.Model.Options.DrawSelectionOptions = GridDrawSelectionOptions.ReplaceBackground | GridDrawSelectionOptions.ReplaceTextColor;
this.grid.Model.Options.HighlightSelectionBackground = Brushes.Blue;
this.grid.Model.Options.HighlightSelectionForeground = Brushes.White;

For your reference we have also attached the sample herewith.

GridDataControl:< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDC1640753944.zip >

GridControl:< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GC1485855858.zip >

Please let us know if you have any queries.

Thanks,
Rajasekar




Loader.
Live Chat Icon For mobile
Up arrow icon