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.
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.
ADAdministrator Syncfusion Team 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.
SBStefan BarrettJanuary 18, 2005 07:55 AM
No, I''m doing the following:
this[row, index+1].Control = GenerateControl( col );
ADAdministrator Syncfusion Team 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.
SBStefan BarrettJanuary 19, 2005 03:44 AM
No, sorry didn''t make this clear.
A different instance is going into every cell.
ADAdministrator Syncfusion Team 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).
SBStefan BarrettJanuary 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?
ADAdministrator Syncfusion Team 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.