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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Display PushButton conditionally

Thread ID:





62028 Jun 6,2007 04:46 PM UTC Jun 6,2007 09:01 PM UTC WinForms 1
Tags: Grouping
Josh King
Asked On June 6, 2007 04:46 PM UTC

I am adding a PushButton to an UnboundField through the GridTableDescriptor. I do not want the push button to display on each record. Is there a way I can hide the PushButton based on a condition in my child table data?

Thank you,

Rajagopal [Syncfusion]
Replied On June 6, 2007 09:01 PM UTC

Hi Josh,

You can handle the QueryCellStyleInfo event to do this. In the event handler code, you can loop through the records of the childtable untill specified condition is satisfied and then hide the pushbutton in the parentrecord by setting the celltype to textbox. Please refer the attached sample for more details. Below is the code snippet.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell
&& e.Style.CellType == "PushButton")
Element el = e.TableCellIdentity.DisplayElement;
Record rec = el.ParentRecord;
if (rec.HasNestedTables)
foreach (GridRecord gr in el.ParentRecord.NestedTables[0].ChildTable.Records)
bool chk = (bool)gr.GetValue("Check");
if (chk)
e.Style.CellType = "TextBox";
void gridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e)
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
if (style.TableCellIdentity.TableCellType != GridTableCellType.RecordPlusMinusCell)
string str = string.Format("Clicked on recordindex: {0}", style.TableCellIdentity.DisplayElement.GetRecord().GetSourceIndex());
MessageBox.Show(str, "Click!", MessageBoxButtons.OK, MessageBoxIcon.Information);

Here is a sample http://websamples.syncfusion.com/samples/Grid.Windows/F62028/main.htm



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon