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.

Custom Control in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

28778 May 10,2005 02:00 PM May 12,2005 05:48 AM Windows Forms 5
loading
Tags: GridControl
Maqsood Ahmed
Asked On May 10, 2005 02:00 PM

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 02:18 PM

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 01:50 AM

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 04:35 PM

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 01:41 AM

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 05:48 AM

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\3.2.1.0\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\3.2.1.0\Windows\Grid.Windows\Samples\DataBound\RepeaterUserControlSample.

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.

;