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.

Dynamic changing cell content of grid

Thread ID:





23705 Jan 18,2005 06:54 AM Jan 19,2005 09:47 AM Windows Forms 7
Tags: GridControl
Stefan Barrett
Asked On January 18, 2005 06:54 AM

Attempting to put a control (own combobox inheriting from Microsoft combobox) into cells of grid. In own combobox, am changing look by capturing message 15 in the WndProc function. Getting a number of problems, related to how the control looks 1. Quite often, when leaving a control, it falls back to standard Microsoft look, but not always. 2. When resize column, sometimes seem to get two controls, one standard one which has resized, and the custom one which does not. Once drop down (on either drop down), the situation corrects itself. 3. etc. I believe I read somewhere that cells, which don’t have the focus, are rendered off-screen, and a bitmap is taken which is shown onscreen. It looks like this does not always happen, and that when resizing can have both control and bitmap. Can’t seem to get this to work correctly, so started looking at another solution. This would involve the control only being visible when the cell had the focus, and plain text being displayed when not having the focus. So, any thoughts on what I have to do, to get the controls to show correctly in the grid? And failing that, how do I only show the control when the cell has the focus, reverting back to plain text cell otherwise.

Administrator [Syncfusion]
Replied On January 18, 2005 07:26 AM

You are deriving a cellrenderer class and a cellmodel class to create your cell control, correct? Are you follwing the technique shown in the grid\samples\cellypes\calendarcells that show how to put a callendar in a grid cell? In particular, do you have two instances of your control, one to handle the active drawing an done to handle the non-active drawing? Not having two instances might cause problems as you described. Normally, you control exactly what gets drawn depending upon whether the cell is active or not, by having two execution paths in the renderer''s OnDraw override. The override in the calendar cells sample does this, but if you have the source code, take a look at the GridTextBoxCellRenderer.OnDraw to see how it is handled there.

Stefan Barrett
Replied On January 18, 2005 07:55 AM

No, I''m doing the following: this[row, index+1].CellType="Control"; this[row, index+1].Control = GenerateControl( col );

Administrator [Syncfusion]
Replied On January 18, 2005 09:01 AM

You can only place such controls in a single cell. Are you trying to put the same control in more than one cell? If so, then you would need to use the technique shown in the calender cell''s sample.

Stefan Barrett
Replied On January 19, 2005 03:44 AM

No, sorry didn''t make this clear. A different instance is going into every cell.

Administrator [Syncfusion]
Replied On January 19, 2005 04:46 AM

The control celltype sends a WM_PRINT (not WM_PAINT) message when it generates the bitmap to display the inactive control. So, if you are doing your drawing only for msg=0xf (WM_PAINT), then you are not drawing when the static bitmap is being generated, ie when msg=0x317 (WM_PRINT).

Stefan Barrett
Replied On January 19, 2005 08:53 AM

I captured 0x317, and for good measure 0x318 (WM_PAINTCLIENT), but neither seems to help. I notice that the cells (which don''t contain focus) that show the controls with the customized look, don''t repaint correctly, while the cells containing controls which don''t show the customization, do repaint. Is there anything special I have to do to be able to capture the WM_PRINT event? Also, what about the workaround, of only showing the customized control when cell has focus, otherwise showing SyncFusion text box?

Administrator [Syncfusion]
Replied On January 19, 2005 09:47 AM

>>Also, what about the workaround, of only showing the customized control when cell has focus, otherwise showing SyncFusion text box? You could handle the DrawCell event. If teh cell being drawn is a non-current custom cell, then draw the text (you can use GridStaticCellRenderer.DrawText static method to do this), and then set e.Cancel = true so the grid will not try to draw the cell. You can also derive a cell control to do this, but the DrawCell event is probably simpler.


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.