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

on TableControlPushButtonClick pushbutton text change or disable

Thread ID:

Created:

Updated:

Platform:

Replies:

131281 Jul 1,2017 10:07 AM UTC Dec 5,2018 06:53 AM UTC WinForms 5
loading
Tags: GridGroupingControl
ketan
Asked On July 1, 2017 10:07 AM UTC


hello sir/madam
i am using SyncfusionGridGroupingControl and inside one push button.
i want to change pushbutton text on TableControlPushButtonClick using c# code,so please help me how can i do

thank u in advance.

Arulpriya Ramalingam [Syncfusion]
Replied On July 3, 2017 12:00 PM UTC

Hi ketan, 

Thank you for using Syncfusion products. 

In order to change the Button Text when the button is clicked, the QueryCellStyleInfo and TableControlPushButtonClick events can be used. In QueryCellStyleInfo event the Description property can be used to set the PushButtonText. Please make use of below code and sample, 

//Event Triggering 
gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo; 

//Event Customization 
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if(e.TableCellIdentity != null && e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.MappingName == "Button") 
    { 
        string key = e.TableCellIdentity.RowIndex.ToString() + e.TableCellIdentity.ColIndex.ToString(); 
        if (description.Count > 0 && description.ContainsKey(key)) 
        { 
            string value = description[key]; 
            if (description.Count > 0 && !String.IsNullOrEmpty(value)) 
            { 
                e.Style.Description = value; 
            } 
        } 
    } 
} 
//Event Triggering 
gridGroupingControl1.TableControlPushButtonClick += GridGroupingControl1_TableControlPushButtonClick; 
 
//Event Customization 
private void GridGroupingControl1_TableControlPushButtonClick(object sender, GridTableControlCellPushButtonClickEventArgs e) 
{ 
    rowIndex = e.Inner.RowIndex; 
    colIndex = e.Inner.ColIndex; 
    string key = rowIndex.ToString() + colIndex.ToString(); 
    if (!description.ContainsKey(key)) 
    { 
        description.Add(key, "Start"); 
    } 
    else 
    { 
        string value = description[key]; 
        if (value == "Start") 
            description[key] = "Stop"; 
        else 
            description[key] = "Start"; 
    } 
} 

 
Note: 
The TableControlCellButtonClicked event can also be used instead of TableControlPushButtonClick event. 


Regards, 
Arulpriya 


Susheel
Replied On December 4, 2018 07:40 AM UTC

Hi AnuPriya,

can you please share a sample on how to change button text in grid grouping control with dynamic grid binding.

Thanks
Susheel

Arulraj A [Syncfusion]
Replied On December 4, 2018 12:06 PM UTC

Hi Susheel, 

Thanks for using Syncfusion product. 

To change the button text for dynamic grid binding, you could use the Description property in QueryCellStyleInfo event. Please refer the following code example, 

Code example 
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo; 
 
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity == null || e.TableCellIdentity.Column == null) 
        return; 
 
    if (e.TableCellIdentity.Column.Name == "Button" && e.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record) 
    { 
        var record = e.TableCellIdentity.DisplayElement.GetRecord(); 
        string text = record.GetValue("Button").ToString(); 
        e.Style.Description = text; 
    } 
} 
 
To change the button text when clicking, you could use the PushButtonClick event. Please refer the following code example, 

Code example 
this.gridGroupingControl1.TableControlPushButtonClick += GridGroupingControl1_TableControlPushButtonClick; 
 
private void GridGroupingControl1_TableControlPushButtonClick(object sender, GridTableControlCellPushButtonClickEventArgs e) 
{ 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    var record = style.TableCellIdentity.DisplayElement.GetRecord(); 
    if (record != null) 
    { 
        string text = style.CellValue.ToString(); 
        if (text.Equals("Start")) 
            record.SetValue("Button", "Stop"); 
        else if (text.Equals("Stop")) 
            record.SetValue("Button", "Start"); 
        else if (text.Equals("On")) 
            record.SetValue("Button", "Off"); 
        else if (text.Equals("Off")) 
            record.SetValue("Button", "On"); 
        else if (text.Equals("Click")) 
            record.SetValue("Button", "Clicked"); 
        else if (text.Equals("Clicked")) 
            record.SetValue("Button", "Click"); 
        else if (text.Equals("Press")) 
            record.SetValue("Button", "Pressed"); 
        else if (text.Equals("Pressed")) 
            record.SetValue("Button", "Press"); 
    } 
} 
 
 
Arulraj A 


Susheel
Replied On December 4, 2018 01:58 PM UTC

Thank you Anulraj, worked perfectly :-)

Regards,
Susheel

Arulraj A [Syncfusion]
Replied On December 5, 2018 06:53 AM UTC

Hi Susheel,  
 
Thanks for the update. 
 
We are glad to know that the provided solution worked at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Arulraj A 


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.

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

;