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.

Retrieving DataRow from Grouped grid checkbox-click

Thread ID:

Created:

Updated:

Platform:

Replies:

18883 Sep 12,2004 10:32 PM Jan 15,2009 01:37 AM Windows Forms 7
loading
Tags: Grouping
David Llewellyn
Asked On September 12, 2004 10:32 PM

Hello, I am trying to use a Grouping grid to display records that contain CheckBoxes. I have been able to create and display the data, but now I want to be able to get the current row information, from the ''clicked'' checkbox''s row. I can use the ''grid.TableControlCheckBoxClick'' to create an event and retrieve a row index from ''e.Inner.RowIndex'', but this is the incorrect index for the datasource. This is the index of the grid. I can get an index by making a copy of the table and comparing them after the event checkboxclick event has happened. Although I need to use a timer to cause a slight delay in order for the event to actually be triggered and the source data updated. I want to be able to get either the whole row of data or the index (for the data source) to access this record, when the checkbox has been ''clicked''. Any idea''s how I can access the ''selected'' row’s data?? Thanks. David.

Administrator [Syncfusion]
Replied On September 13, 2004 08:43 AM

Maybe code like this will work for you.
private void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
	GridRecordRow rec = this.gridGroupingControl1.Table.DisplayElements[e.Inner.RowIndex] as GridRecordRow;
	if(rec != null)
	{
		DataRowView dr = rec.GetData() as DataRowView;
		Console.WriteLine(dr["Col1"]); //some column
	}
}

David Llewellyn
Replied On September 13, 2004 07:53 PM

Thank you. This code works fine to retrieve the record. BUT it returns the unmodified datarow, as if the CheckBoxClick event has not yet happened. I tried to manually set the checkbox value to true. eg:- table.Rows[recordindex][colindex] = true; But this causes additional events to be triggered and some strange effects happen. I could use a timer to allow the checkboxclick event to actually take place before trying to access that specific record, but I don’t want to rely on timers for this. Is there some other event that I could use which will allow me to access the modified and updated record that has just been ''clicked''??? Or is there a way to modify this record in the datatable, without causing additional messages to be triggered??? Thanks. David.

Administrator [Syncfusion]
Replied On September 14, 2004 02:24 AM

I take it that knowing the bool value is the opposite of teh value you are currently getting is not sufficient for your needs? Anyway, one thing you can to is to explicitly change it your self and cancel the event so the grid does not reset it as part of its normal processing.
private void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
	GridRecordRow rec = this.gridGroupingControl1.Table.DisplayElements[e.Inner.RowIndex] as GridRecordRow;
	if(rec != null)
	{
		DataRowView dr = rec.GetData() as DataRowView;
		dr["bool"] = ! (bool) dr["bool"];
		dr.EndEdit(); //maybe???
		e.Inner.Cancel = true;
		Console.WriteLine(dr["bool"]);
	}
}

David Llewellyn
Replied On September 14, 2004 04:18 PM

Thank you for your help. This code is exactly what I needed to solve my problem. Thanks again.

Sameer Khan
Replied On January 13, 2009 08:41 AM

Is there a way to get the check box change event on a cell of a GridGroupingControl?

TableControlCheckBoxClick is only fired if the user uses a mouse to click on the check box; but not when the user uses the space bar to change the check status.




Sameer Khan
Replied On January 13, 2009 11:00 AM

Handling the Key up event and checking for the Space Key worked.

-S


Nisha Arockiya A [Syncfusion]
Replied On January 15, 2009 01:37 AM

Hi Sameer,

Thanks for sharing information with us.

Please let us know any other concerns.

Regards,
Nisha.


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.

;