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.

Syncfusion GridGenericControlCellRenderer OnDraw Method error

Thread ID:

Created:

Updated:

Platform:

Replies:

21434 Nov 10,2004 05:57 AM Nov 11,2004 07:04 AM Windows Forms 4
loading
Tags: GridControl
Harsha Alakeshwar
Asked On November 10, 2004 05:57 AM

I have created my own customrenderer extending the GridGenericControlCellrenderer. the custom renderer was written for a specific usercontrol. I wanted to show this usercontrol when the cell has focus and a normal labeltext with the value in it when the cell does not have focus. this is the code i had used to acheive this in the ondraw method protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) { clientRectangle.Size = GridUtil.Max (new Size(clientRectangle.Width , clientRectangle.Height) , new Size(clientRectangle.Width,DOUBLEUNIT_HEIGHT)); if ( this.ShouldDrawFocused(rowIndex , colIndex) == true ) { style.Control = this.newTextBox; DoubleUnitTextBoxCellModel.InitializeUnitTextBox(this.newTextBox , style); } else { style.Control = this.label; DoubleUnitTextBoxCellModel.InitializeLabel(this.label , style); } base.OnDraw (g, clientRectangle, rowIndex, colIndex, style); } newTextBox happens to be my usercontrol. I get a hdc error message on the base.ondraw method call. I had replaced the label with another of my usercontrols and the code works fine. but when i replaced both my usercontrols with 2 labels the code crashes again with the same error. i observed that when i comment style.control = label the code works fine again. Please help Regards Harsha

Administrator [Syncfusion]
Replied On November 10, 2004 08:24 AM

Have you looked at the grid\samples\celltypes\calendarcells sample? It does something very close to this, except it uses two of the same controls (MonthCalendars) and not two different controls. In particular, does your code have use the same calls in the renderer''s constructor like this sample does? (SetFixedControl and SetControl)?

Administrator [Syncfusion]
Replied On November 11, 2004 02:15 AM

Yes i have looked at the MonthCalendar example. I do use the SetFixedControl and the SetControl methods. the code is as follows this.FixControlParent(label); this.SetControl(newTextBox); so the editable control is my customcontrol and the drawcontrol would be the label. Harsha >Have you looked at the grid\samples\celltypes\calendarcells sample? It does something very close to this, except it uses two of the same controls (MonthCalendars) and not two different controls. > >In particular, does your code have use the same calls in the renderer''s constructor like this sample does? (SetFixedControl and SetControl)?

Administrator [Syncfusion]
Replied On November 11, 2004 03:18 AM

If it works when you do not use the label in the Draw method, you could not use the label and instead use the static method GridStaticCellRenderer.DrawText to draw teh text in the cell and not call the base class in this case. If this does serve your purposes, then if you post a sample project showing this problem with your derived control, maybe I can suggest something else.

Administrator [Syncfusion]
Replied On November 11, 2004 07:04 AM

Thank you that works

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.

;