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. Image for the cookie policy date
close icon

Checkbox and SetValue

Hi, how can i set checkboxes in a Celltype = CheckBox Column to state checked ?? I already tried true and false according to the values given the CheckBoxOptions Section in the designer but with no luck. Am i missing anything ??

10 Replies

AD Administrator Syncfusion Team April 4, 2005 03:02 PM UTC

Additionally, how can i determine if the current record is a record of the child table or not ?? rec.ParentRecord is always null. Thanks


AD Administrator Syncfusion Team April 4, 2005 05:16 PM UTC

If this is a GroupingGrid, then you set values in a checkbox by using record.SetValue to set the appropriate value in the underlying data. If the System.Type of this column is bool, then you would have code like rec.SetValue("MyBoolField", true). I am not sure what you know when you want to find our whether a record is in a child or not. Here is code you can use for TableControlCurrentCellMoved.
private void gridGroupingControl1_TableControlCurrentCellMoved(object sender, GridTableControlCurrentCellMovedEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
	if(style.TableCellIdentity.Table.Equals(this.gridGroupingControl1.Table)
		&& ( style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell ||
				style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell))			
	{
		Console.WriteLine("TopLevel");
	}
	else
	{
		Console.WriteLine("Nested");
	}
}


AD Administrator Syncfusion Team April 5, 2005 07:37 AM UTC

Hi, it is a GridGroupingControl. I did as you suggested. I set the Celltype of the column to Checkbox and the CellValueType to System.Boolean. Now I use record.SetValue("CheckBoxColumn", true). But my boxes still remain unchecked. What can the problem be ?


AD Administrator Syncfusion Team April 5, 2005 08:13 AM UTC

Depending upon the edit state of the record, you may have to call record.BeginEdit and record.EndEdit to make the changes. Here is a little sample. When you make a row current. the bool value is set true in tableControlCurrentCellMoved. There is also a button that will flip the bool value in the current row. http://www.syncfusion.com/Support/user/uploads/GGC_BookMark_bfd0a948.zip


AD Administrator Syncfusion Team April 5, 2005 03:03 PM UTC

Yes it works on the parent table. But when i try to do the same thing on the nested child table then none of the cells gets checked. I think this is because i can''t reference a child column using the rec.SetValue("childCheckRow", true) command. Can you tell me how i can get a reference to a child column or explicitly loop only the child columns ? I''m working in the ctor of the form, so i''m looping all records using GGC.Table.Records Collection. thanks


AD Administrator Syncfusion Team April 5, 2005 05:33 PM UTC

You have to recursively access the nestedtables to locate a record in a nested table. Here is a sample that flips a boolean value on teh current record whether it is in a parent table or the child table. http://www.syncfusion.com/Support/user/uploads/GGC_BookMark_de4c1ecc.zip


AD Administrator Syncfusion Team April 6, 2005 08:00 AM UTC

I get an error in your sample in line: int offset = gnt.ChildTable.GetFirstRecord().GetRowIndex()- gnt.ChildTable.GetRowIndex(); Message:''Syncfusion.Grouping.Record'' does not contain a definition for ''GetRowIndex'' could you please tell me a way to correct this ?


AD Administrator Syncfusion Team April 6, 2005 09:07 AM UTC

What version of our library are you using? I ran the sample using 3.0.1.0.


AD Administrator Syncfusion Team April 6, 2005 09:41 AM UTC

same as you: 3.0.1.0. All assemblies except for Syncfusion.WebServer are listed in the GAC as Version 3.0.1.0 Suggestions


AD Administrator Syncfusion Team April 6, 2005 10:27 AM UTC

I was using a debug build of our 3.0.1.0. That method is exposed in the debug build but not in the release build. I will have to discuss why this was done with Stefan, the grid architect. There must be another way to get at this information that I am not seeing. Anyway, for now, to get that code working in release, you can add this method to the form class,
public int GetRowIndex(Element el)
{
	return this.gridGroupingControl1.Engine.Table.NestedDisplayElements.IndexOf(el);
}
Then replace the offending line with this line: int offset = GetRowIndex((GridRecord)gnt.ChildTable.GetFirstRecord())- GetRowIndex(gnt.ChildTable);

Loader.
Live Chat Icon For mobile
Up arrow icon