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.

PushButton cell type with dynamic button text and handler

Thread ID:

Created:

Updated:

Platform:

Replies:

131913 Aug 2,2017 05:16 PM Aug 8,2017 04:58 AM Windows Forms 3
loading
Tags: GridGroupingControl
John Virgolino
Asked On August 2, 2017 05:16 PM

We are using v15.2.0.40 of the GridGroupingControl and wish to have one column be a pushbutton. The text for the pushbutton should be the text value that is in the datasource (in our case a List<T>). This way each button of each row shows the value for that row in the column. The handler for the button should pass the value of the cell so we can generate a dynamic link when the button is pressed.

I have changed the cell type to pushbutton for the column under AnyRecordFieldCell and push buttons appear, but the face is blank. Also, which event should I be capturing when the users clicks on the button that will give me access to the value so we can generate a dynamic link from there.

Thanks!

Mohanraj Gunasekaran [Syncfusion]
Replied On August 3, 2017 06:03 AM

Hi John,   
   
Thanks for using Syncfusion product.   
   
In order to get the push button cell value underlying data source when click on the push button cell, you can use the CellValue property in TableControlCellButtonClicked event. Please refer to the below code example,   
   
Code example   
this.gridGroupingControl1.TableControlCellButtonClicked += gridGroupingControl1_TableControlCellButtonClicked;   
   
void gridGroupingControl1_TableControlCellButtonClicked(object sender,GridTableControlCellButtonClickedEventArgs e)   
{   
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);   
    MessageBox.Show("Push button cell value: " + style.CellValue.ToString());   
}   
   
   
Please refer the below UG link   
   
Suggestion 2:   
If you want to set the cell value for push button text, you can use the Description and Cell Value property in QueryCellStyleInfo event. Please refer to the below code example and sample,   
   
Code example   
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;   
   
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)   
{   
    if (e.TableCellIdentity == null || e.TableCellIdentity.Column == null)   
        return;   
   
    if (e.TableCellIdentity.Column.Name == "Country")   
    {   
        e.Style.Description = e.Style.CellValue.ToString();   
        e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;   
    }   
}   
   
   
Note:   
If you have used the QueryCellStyleInfo event to set the text for button, you can get the cell value using Button.Text property in TableControlCellButtonClicked event. Please refer to the below code example,   
   
Code example   
void gridGroupingControl1_TableControlCellButtonClicked(object sender,GridTableControlCellButtonClickedEventArgs e)   
{   
    MessageBox.Show("Push button cell value: " + e.Inner.Button.Text);   
}   
   
   
   
Sample link: GridGroupingControl   
   
Regards,   
Mohanraj G   
 


John Virgolino
Replied On August 7, 2017 01:29 PM

Mohanraj,

This worked perfectly! Thanks for the help!


Mohanraj Gunasekaran [Syncfusion]
Replied On August 8, 2017 04:58 AM

Hi John, 
 
Thanks for your update. 
 
We are glad to know that your reported problem has resolved. 
 
Please let us know if you have any further assistance. 
 
Regards, 
Mohanraj G 


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.

;