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

How to change the border color for static cells that have focus and use the standard border color for regular cell

When the current cell is a static cell, I want to change the cell border color to a different color or prevent the cell from having a border at all, so as to indicate to the user that the cell is not editable. How can I go about doing this?

Also, How can I select the all the text in the active cell or move the mouse caret to the beginning of the text instead of at the end?

3 Replies

AD Administrator Syncfusion Team December 1, 2006 05:38 AM UTC

Hi James,

Issue 1:

You can handle the TableControlPrepareViewStyleInfo event and change the border style of the static current cell by checking Style.Celltype and e.RowIndex/ColIndex. Here is a code snippet to show this.

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableControl tc = e.TableControl as GridTableControl;
if( tc.CurrentCell.RowIndex == e.Inner.RowIndex && tc.CurrentCell.ColIndex == e.Inner.ColIndex
&& e.Inner.Style.CellType == "Static" )
{
e.Inner.Style.Borders.All = new GridBorder(GridBorderStyle.Solid,Color.Blue);
}
}

Issue 2:

There is a property to specify the current cell active behavior when moving the current cell or click inside the current cell. You can specify it using this code:

this.gridGroupingControl1.TableControl.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;

Please refer the attached sample for implementation.
GGCStaticBorderStyle.zip

Best Regards,
Haneef


JB James Blibo December 1, 2006 05:55 AM UTC

The black border is still showing. The code just adds another border around the cell. In this sample, is you selected a lighter color for the new border color, you will see that the black border is still there, in addition to the new border.


AD Administrator Syncfusion Team December 4, 2006 05:19 AM UTC

Hi James,

You can use the ShowCurrentCellBorderBehavior property to control the currentcell border/frame in a grid. Here is a code to hide the default currentcell border.

this.gridGroupingControl1.TableControl.Model.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon