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 : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Control in GDBG

Thread ID:





28778 May 10,2005 06:00 PM UTC May 12,2005 09:48 AM UTC WinForms 5
Tags: GridControl
Maqsood Ahmed
Asked On May 10, 2005 06:00 PM UTC

Hello, I want to clarify that is there any way that I can use my custom control as a CellType in GridDataBoundGrid. I want to display a checkbox and a combobox in same cell (vertically). Is it achievable without introducing custom control and using Syncfusion grid itself. Thanks in Advance Maqsood Ahmed Kolachi Advanced Technologies http://www.kolachi.net

Administrator [Syncfusion]
Replied On May 10, 2005 06:18 PM UTC

If it is a single cell that you want to do this with, you can set the style.CellType = "Control" and set style.Control = yourUserControl. Here is a little snippet that adds a standard TextBox control to a cell. TextBox box = new TextBox(); box.Multiline = true; box.Text = "Some random text here..."; box.BorderStyle = BorderStyle.None; gridControl1.RowHeights[2] = 30; gridControl1.ColWidths[2] = 200; gridControl1[2,2].CellType = "Control"; gridControl1[2,2].Control = box; this.Controls.Add(box);

Maqsood Ahmed
Replied On May 11, 2005 05:50 AM UTC

Thanks Clay, It worked. Will please help me to know that which is the best point to add custom control to grid. As I don''t want to set it multiple times. I have tried PrepareViewStyle nad Model.QueryCellInfo. But I think it adds control multiple times, because I can see three Combobox buttons all working on click :S TIA Maqsood Ahmed Kolachi Advanced Technologies http://www.kolachi.net

Administrator [Syncfusion]
Replied On May 11, 2005 08:35 PM UTC

If you are using a GridControl, then you can do it in Form.Load. If you are using a GridDataBoundGrid, then you need ot do it in grid.Model.QueryCellInfo. BUT, you should only create the control in Form.Load. In QueryCellInfo, you should only set the e.Style.CellType and e.Style.Control.

Maqsood Ahmed
Replied On May 12, 2005 05:41 AM UTC

Hello, Please have a look at the attached sample. It''ll give you a clearer picture about what i am trying to do. I want to add this control to the grid on the basis of certain data. otherwise it''ll display normal static fields. Will it be a good idea to make single instance of a control, since each control on the grid needs to show different data. Thanks in Advance. SyncfusionTest_4033.zip

Administrator [Syncfusion]
Replied On May 12, 2005 09:48 AM UTC

You do not want to be cfreating a new user control every time PrepareViewStyleInfo is hit. Either you create a whole collection of your user controls once in form.load, one for each cell. Then in Model.QueryCellInfo, you retrieve the proper UserControl from your collection (based on e.RowIndex or something else) and set it to e.Style.COntrol. This way you are only creating each control once per row and not millions of times (one for each hit of QueryCellInfo.) If you onbly have 4 or 10 rows in your grid, this will likely work OK. But if you are going to have thousands of rows in your grid, you will need to actually deive a celltype that support control sharing among cells. There is a section in the user guide on deriving celltypes and we ship many samples. Here is one sample, \Syncfusion\Essential Studio\\Windows\Grid.Windows\Samples\CellTypes\CalendarCells. You can also look at this sample that puts a UserControl in a cell using a derived celltype. \Syncfusion\Essential Studio\\Windows\Grid.Windows\Samples\DataBound\RepeaterUserControlSample.


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