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.

Checkbox and SetValue

Thread ID:

Created:

Updated:

Platform:

Replies:

26933 Apr 4,2005 10:56 AM Apr 6,2005 06:27 AM Windows Forms 10
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 4, 2005 10:56 AM

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 ??

Administrator [Syncfusion]
Replied On April 4, 2005 11:02 AM

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

Administrator [Syncfusion]
Replied On April 4, 2005 01:16 PM

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");
	}
}

Administrator [Syncfusion]
Replied On April 5, 2005 03:37 AM

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 ?

Administrator [Syncfusion]
Replied On April 5, 2005 04:13 AM

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

Administrator [Syncfusion]
Replied On April 5, 2005 11:03 AM

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

Administrator [Syncfusion]
Replied On April 5, 2005 01:33 PM

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

Administrator [Syncfusion]
Replied On April 6, 2005 04:00 AM

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 ?

Administrator [Syncfusion]
Replied On April 6, 2005 05:07 AM

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

Administrator [Syncfusion]
Replied On April 6, 2005 05:41 AM

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

Administrator [Syncfusion]
Replied On April 6, 2005 06:27 AM

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);

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.

;