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

Adding a Numeric Text box as a cell type

How do I add a Numeric Cell Box [or any other user control] as a cell type for a GridGroupingControl Column?


2 Replies

SK Sameer Khan December 23, 2008 04:06 PM UTC

btw .. I tried adding the following code:

e.Style.Control = new NumericTextBox();

and it doesn't seem to work

>How do I add a Numeric Cell Box [or any other user control] as a cell type for a GridGroupingControl Column?





NA Nisha Arockiya A Syncfusion Team December 24, 2008 09:54 AM UTC

Hi Sameer,

Thanks for your interest in syncfusion Products.

You can place an UserControl in a single cell using Style property in QueryCellStyleInfo event .Please refer to the code below:

private Dictionary controls = new Dictionary();

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
GridColumnDescriptor columnDescriptor = e.TableCellIdentity.Column;
if (e.TableCellIdentity.RowIndex == 6 && e.TableCellIdentity.ColIndex == 5)
{
controls.Add(e.TableCellIdentity, new UserControl1());
e.Style.CellType = "UserControl1";
e.Style.Control = controls[e.TableCellIdentity];
}
}



The Control celltype is only intended to be used in a single cell. There is no mechanism implemented to move values from the cell style to the control or from the control to the cellstyle which is how you can use a single control among many cells.

If you want to use a control for multiple cells, then the recommended way would be to derive your own cell control. You would override the renderer's OnInitialize method to move the state information from the style object to your control. Your would also override the OnSaveChanges method to move the state information from your control back to the style. These are the techniques used for sharing controls. There are several samples listed in the Users Guide, and there are several more in the CellTypes samples folder. If you do a search for CellRenderer in our Samples folder, you will see many, many hits for derived cell controls.

Let me know if you have further questions on this matter.

Regards,
Nisha



Loader.
Live Chat Icon For mobile
Up arrow icon