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.

Problem with check box columns in nested entities

Thread ID:

Created:

Updated:

Platform:

Replies:

65262 Jul 25,2007 12:55 PM Jul 27,2007 10:12 PM Windows Forms 3
loading
Tags: GridControl
dinesh upreti
Asked On July 25, 2007 12:55 PM

I am using GGC and using nested entities to bound the data.

Following snippets will give you an idea how i am designing the grid for parent and child entities. Note that for boolan data, i want to display check boxes.

// adding partent data
private void AddParentBoundColumn(string columnName, string toolTipText)
{

dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;

PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);

if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}

}

// adding child data
private void AddChildBoundColumn(string columnName, string toolTipText)
{

dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;

PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);

if (pd != null &&
pd.PropertyType.Equals(typeof(bool)))
{
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
}
}

Every thing is working fine except for TableControlCurrentCellChanged event.

For the child data, I am able to hit this event when i click on a check box for child data. But this is not happeing for when i check a cell at the parent level.

Please advice.

Just to add to this, if i comment the code as shown below for parent columns , it shows dropdowns instead of checkboxes, which is not desired. But in that case when i change the value in drop down the event does get fired.


private void AddParentBoundColumn(string columnName, string toolTipText)
{

dgRangePlanGrid.TableDescriptor.Columns.Add(columnName, columnName);
dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.CellTipText = toolTipText;

PropertyDescriptor pd = _rangePlanGridController.GetPropertyDescriptor(columnName);

// if (pd != null &&
// pd.PropertyType.Equals(typeof(bool)))
// {
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
// dgRangePlanGrid.TableDescriptor.Columns[columnName].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Center;
// }

}



haneefm [Syncfusion]
Replied On July 25, 2007 07:08 PM

Hi Dinesh,

At runtime, you can set celltype of the child table column using below code:

GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";

You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.

this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);

void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}

Best regards,
Haneef

dinesh upreti
Replied On July 26, 2007 05:03 AM

hi,
the problem with TableControlCheckBoxClick
event is that it doesnt get fired if the user checks a checkbox using space bar.

Thanks



>Hi Dinesh,

At runtime, you can set celltype of the child table column using below code:

GridTableDescriptor td = this.gridGroupingControl1.GetTableDescriptor("RelationNameOrTableName");
td.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "CheckBox";

You can use the TableControlCheckBoxClick event to detect check changes in a grid and let me know if this helps.

this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);

void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
Console.WriteLine("check box click");
}

Best regards,
Haneef

Rajagopal [Syncfusion]
Replied On July 27, 2007 10:12 PM

Hi Dinesh,

Thanks for your patience.

You could try the code below in the TableControlCurrentCellKeyDown event of the grid, to detect the changes made to the checkbox cells through spacebar.

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if(e.Inner.KeyCode == Keys.Space && cc.Renderer.StyleInfo.CellType == "CheckBox")
Console.WriteLine("CheckBox state changed");
}

Let us know if you have any further questions.

Have a nice time.
Regards,
Rajagopal

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.

;