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.
Unfortunately, activation email could not send to your email. Please try again.

Display PushButton conditionally

Thread ID:

Created:

Updated:

Platform:

Replies:

62028 Jun 6,2007 12:46 PM Jun 6,2007 05:01 PM Windows Forms 1
loading
Tags: Grouping
Josh King
Asked On June 6, 2007 12:46 PM

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,
Josh

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

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";
break;
}
}
}
}
}
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

Regards,
Rajagopal

CONFIRMATION

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.

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.

;