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.

Button inside a Grid column

Thread ID:

Created:

Updated:

Platform:

Replies:

95874 Aug 5,2010 10:22 PM Nov 15,2010 06:39 AM WPF 7
loading
Tags: GridControl
Valiyaveettil Jitesh Ramanathu
Asked On August 5, 2010 10:22 PM

Hi,

I want to add a button inside a Grid control, and this is how I am doing it.








and inside my class, I do

this.MyGrid.CellButtonClick += new GridCellButtonClickEventHandler(MyGrid_CellButtonClick);

I do see a button, but the on click event does not get fired. What could be wrong?

Thanks,
Jitesh

Muthulakshmi N [Syncfusion]
Replied On August 6, 2010 08:06 AM

Hi Jitesh,

Thank you for your details.
By handling this.MyGrid.CellClick += new GridCellClickEventHandler(MyGrid _CellClick)
event you can listen the action of the button which is present inside the UnboundVisibleColumn of the GDC .

Let us know if you need any details.

Thanks,
Muthulakshmi

Valiyaveettil Jitesh Ramanathu
Replied On August 6, 2010 01:59 PM

That works. Thank you.

Jitesh

Muthulakshmi N [Syncfusion]
Replied On August 12, 2010 02:09 AM

Hi Jitesh,

Thank you for your update.

Let us know if you need any details.

Thanks,
Muthulakshmi


Scott Jeslis
Replied On August 19, 2010 01:12 PM

This doesn't seem to work if the button doesn't completely fill the cell, use this XAML for example:








Muthulakshmi N [Syncfusion]
Replied On August 25, 2010 01:27 AM

Hi Jitesh,

Thank you for your details.

Here we have prepared a sample which illustrates your request. Please download the sample from the below location.

Link: http://www.syncfusion.com/uploads/redirect.aspx?file=ButtoninUnboundGDC_2edadb33.zip&team=development

Using below xaml you can activate the button which is present inside the UnboundColumn of GridDataControl.

[xaml snippet]







MappingName="unboundColumn"
HeaderText="unboundColumn "
CellTemplate="{StaticResource AddButtonTemplate}" />

Let us know if you need any details.

Thanks,
Muthulakshmi

Valiyaveettil Jitesh Ramanathu
Replied On October 13, 2010 05:28 PM

Hi,

Your previous suggestion helped and I was able to capture the CellClick event. But, my event handler does not tell me which is the row from which the cell is clicked. The rowIndex from eventArgs return the row Id, but that information is not useful after the user sorts my Grid on one of the columns. I thought of binding to SlectedItem, but that returns null.

Can you please tell me how I can access the data object corresponding to specific row that is clicked?

Thanks,
Jitesh


Kamalakannan A [Syncfusion]
Replied On November 15, 2010 06:39 AM


Hi Jitesh,

Sorry for the delay caused.

The Cell row column index can be calculated from the mouse button down point using PointToCellRowColumnIndex() method as follows.

[Code Snippet [C#]

this.grid.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(grid_PreviewMouseLeftButtonDown);

void grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
RowColumnIndex RowCol = grid.PointToCellRowColumnIndex(e);
}

Let us know if you need any details.

Thanks,
Kamal.



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.

;