Disabling other cell based on value of current cell

Hi haneef ,
thanx for the example,but my requirement is some what different.

I need to disable a cell in GridGroupingControl based on some condition which will occur in some other cell.
if i use gridGroupingControl1_QueryCellStyleInfo,
in eventArgs i get the current cell info and i can disable the current selected cell.
but i need to disable some other cell based on the value of current cell.

7 Replies

PA Pawan Adur December 6, 2006 11:00 AM UTC

hi haneef,
can u plz guide for this.

>Hi haneef ,
thanx for the example,but my requirement is some what different.

I need to disable a cell in GridGroupingControl based on some condition which will occur in some other cell.
if i use gridGroupingControl1_QueryCellStyleInfo,
in eventArgs i get the current cell info and i can disable the current selected cell.
but i need to disable some other cell based on the value of current cell.


AD Administrator Syncfusion Team December 6, 2006 11:37 AM UTC

Hi Pawan,

Here is a forum thread that discuss with a simillar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=52631

Best Regards,
Haneef


PA Pawan Adur December 6, 2006 12:28 PM UTC


Hi haneef,
i have essential studio 3.3.0 , so cannot refer to the example given there.
>Hi Pawan,


Here is a forum thread that discuss with a simillar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=52631

Best Regards,
Haneef


PA Pawan Adur December 6, 2006 01:35 PM UTC

Hi haneef,
i went thru the example. but color applies to whole row and not a single cell.how to do it for single cell.

thanx
pawan

>
Hi haneef,
i have essential studio 3.3.0 , so cannot refer to the example given there.
>Hi Pawan,


Here is a forum thread that discuss with a simillar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=52631

Best Regards,
Haneef


PA Pawan Adur December 11, 2006 07:57 AM UTC

Hi haneef,
that solution didnt solve my query .
plz help
Thanx
pawan

>Hi haneef,
i went thru the example. but color applies to whole row and not a single cell.how to do it for single cell.

thanx
pawan

>
Hi haneef,
i have essential studio 3.3.0 , so cannot refer to the example given there.
>Hi Pawan,


Here is a forum thread that discuss with a simillar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=52631

Best Regards,
Haneef


AD Administrator Syncfusion Team December 11, 2006 09:14 AM UTC

Hi Pawan,

Here is a minimal sample that shows you how to set the style property of the cell such as Enabled,Clikable,BackColor and etc,.depends on the another cell value in a same row. It implements the TableControlPrepareViewStyleInfo event to change the Enabled/BackColor property of the cell by checking the EmpName is equal to "Hazart" in a "Salary" column cell. Here is a code snippet

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo info = e.Inner.Style as GridTableCellStyleInfo;
Element el = info.TableCellIdentity.DisplayElement;
if( el != null && el.Kind == DisplayElementKind.Record)
{
GridRecordRow row = el as GridRecordRow;
if( row != null && row.ParentRecord != null && info.TableCellIdentity.Column != null )
{
//Disable the Salary Column depends on the value present the EmpName column.
//Check the Cell value depends on the "Salary" Column...
if( info.TableCellIdentity.Column.Name == "Salary")
{
//Access the "EmpName" cell value.
object obj = row.ParentRecord.GetValue("EmpName");
if( obj != null && obj.ToString() == "Hazart")
{
e.Inner.Style.Enabled = false;
e.Inner.Style.Clickable = false;
e.Inner.Style.BackColor = SystemColors.Control;
}
}
}
}
}

Please refer to the attached sample for implementation.
GGCCellEnabledProperty.zip

Best Regards,
Haneef


PA Pawan Adur December 11, 2006 02:42 PM UTC


Hi haneef,
thanx for the example. i did that but the usage TableControlPrepareViewStyleInfo is just too costly it seems that grid takes lot of time to repaint . as i am disabling
cells based on other cells value.
Also in the drop down some times the TableControlCurrentCellChanged event is caught but some times the event is not caught.
can i do this in TableControlCurrentCellChanged only.


>Hi Pawan,

Here is a minimal sample that shows you how to set the style property of the cell such as Enabled,Clikable,BackColor and etc,.depends on the another cell value in a same row. It implements the TableControlPrepareViewStyleInfo event to change the Enabled/BackColor property of the cell by checking the EmpName is equal to "Hazart" in a "Salary" column cell. Here is a code snippet

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo info = e.Inner.Style as GridTableCellStyleInfo;
Element el = info.TableCellIdentity.DisplayElement;
if( el != null && el.Kind == DisplayElementKind.Record)
{
GridRecordRow row = el as GridRecordRow;
if( row != null && row.ParentRecord != null && info.TableCellIdentity.Column != null )
{
//Disable the Salary Column depends on the value present the EmpName column.
//Check the Cell value depends on the "Salary" Column...
if( info.TableCellIdentity.Column.Name == "Salary")
{
//Access the "EmpName" cell value.
object obj = row.ParentRecord.GetValue("EmpName");
if( obj != null && obj.ToString() == "Hazart")
{
e.Inner.Style.Enabled = false;
e.Inner.Style.Clickable = false;
e.Inner.Style.BackColor = SystemColors.Control;
}
}
}
}
}

Please refer to the attached sample for implementation.
GGCCellEnabledProperty.zip

Best Regards,
Haneef

Loader.
Up arrow icon