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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to creat a customcelltype in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

64178 Jul 16,2007 03:15 PM UTC Jul 16,2007 05:42 PM UTC WinForms 1
loading
Tags: GridControl
sxd
Asked On July 16, 2007 03:15 PM UTC

i want to creat a custom cell type is "static text + text",the static text is not allow edit ,only display ,the text is user input, this is a customcelltype,how to creat it?

haneefm [Syncfusion]
Replied On July 16, 2007 05:42 PM UTC

Hi Sxd,

You can do this by handling the DrawCell event of the grid and set e.Cancel to true to customize your drawing in a grid cell. Below is a code snippet that show this task.

void gridControl1_DrawCell(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e)
{
if (e.ColIndex == 2 && e.RowIndex > 0)
{
e.Cancel = true;
e.Style.TextMargins.Left = e.Bounds.Width / 2;
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Rectangle rect = e.Bounds;
rect.Width = e.Bounds.Width /2;
e.Graphics.DrawString(e.Style.Description, e.Style.GdipFont, new SolidBrush(e.Style.TextColor), rect);
}
}

Refer attached sample for more details.
GridStaticText.zip

Creating Custom Control :
>>>>>>>>>>>>>>>>>>>>>>

If you want to host this control in a single grid cell, then you can do this by setting the celltype of the cell to be a control and then set the control that you want the cell to be associated with. Below is the code.

this.gridControl1[2,2].CellType = "Control";
this.gridControl1[2,2].Control = userControl1;

If you want to have this control in several cells, then you will have to create a custom celltype deriving the control. It requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell.

Please refer the DerivedCellControlTutorial sample in the browser samples for more details.
[install drive]\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial\

Below are the forum threads that discuss with "Multiple Button control" celltype in a grid.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=50936
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=63201

See this forum thread, CardControl in a gridcell.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=60399

Best regards,
Haneef

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.

Warning Icon 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.Close Icon

;