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

GridGenericControlCellModel - draw problems

Thread ID:





45386 Jun 19,2006 08:16 PM UTC Jun 20,2006 09:17 AM UTC WinForms 3
Tags: GridControl
Colin Bolton
Asked On June 19, 2006 08:16 PM UTC

I am trying to adapt the Calendar example code to place my own control in the cell instead of the calendar. I wish to place a MenuStrip control in the cell so that I can have a a cell with a drop down menu of items which can have sub-menu''s etc. In the final version clicking on a menu item will set the text of the base menu item and hence provide a rich drop down list with icons and sub-folders. Following the example code as closely as I can I still have problems having multiple cells of my custom cell type. I have retained the code which creates two copies of the control, one for the active and one for the inactive cells. This works well for the most part - if a cell is clicked then the appropriate menu drops down as it should. However, if the clicked cell is such that the grid has to move the grid when it gets the focus then clicking on this control firstly moves the grid correctly but then shows an empty cell (background colour correct) with no drop down menu. Further clicks on this cell do nothing and the focus has to be moved from the cell and back again for the menu to appear. This is probably best shown by my quick example attached (apologies for not changing the names from the example). Any ideas?? Cheers Colin


Administrator [Syncfusion]
Replied On June 19, 2006 09:41 PM UTC

Hi Colin, I am realy sorry to inform you that i couldn''t get your question. Colud you please provide me a some more details about this issue? Could you please let me know the version of EssentialStudio, .net framework and windows OS which you are usining? Thanks for your patience. Regards, Haneef

Colin Bolton
Replied On June 20, 2006 08:30 AM UTC

Firstly thanks for the quick reply. Sorry if I didn''t make myself clear previously, it was the end of a long day! Ok versions first: Windows XP Pro version 2002 SP2 Essential Studio .Net 2.0 (Although I have 1.1 installed also - how can I be sure I am using the most recent framework?) I''ve attached a solution which should make the problem obvious, I''ve cleaned the code a little since last night so only what is required is left and most things are named a little more sensibly. What I want to achieve is to have a cell with a MenuStrip control in it, which will contain numerous options in it''s drop down menu. We like the MenuStrip control because it has icons next to the items but more importantly because it can contain folders of menu items. We would like several of these controls in our grid and if the user clicks once on the cell the MenuStrip must display the menu options on the first click (we had some problems previously with the Control cell type where the first click gave the cell focus and then the second click opens up the menu). Following the Calendar example we have almost achieved this. In my example solution there are four such buttons which display only hard coded options but demonstrate the problem. If all four buttons are positioned in the grid such that their cells are completely in view then it works perfectly. Switching from one button to another with a single click opens the appropriate MenuStrip and all is drawn correctly. However, if the MenuStrip to be clicked is in a cell which is partially outside the viewable area for the grid control then the click event causes the data grid to adjust it''s scroll bars so that the newly activated cell is completly in view. In doing so it fails to paint the MenuStrip control in the now active cell and the cell appears blank. A second click on the cell does nothing and to force a re-draw the user must click on another cell and back again for the control to appear correctly. Hopefully this long winded explanation is better than previously. If you open the code I have attached then start the project and click on button you can just see in column D row 2 and you''ll see what I mean (you should see buttons first,third and four but a blank on the cell you have just clicked). Any help most welcome! Cheers, Colin


Colin Bolton
Replied On June 20, 2006 09:17 AM UTC

So I *think* I have solved my problem but I am unsure why this works which makes me a little nervous! As in the calendar example I initialized the active control in the InitializeControlText event and the draw control in the onDraw event. Tracing out these events to a log it seems that when the grid has to move the x position to view the active cell the InitializeControlText event is followed by a number of OnDraw events for the active cell. Somewhere the initialisation of the active cell seems to be lost. However, if I initialise both the active and draw controls in the OnDraw method then it behaves correctly. This *shouldn''t* make any difference as the active control is not un-initialised (or re-initialised to another value) during the OnDraw events but it does make a difference. This does mean that the active control is repeatedly initialised which wont be quick (I guess??). So my question is now, is it not a good idea to initialise the active control in the OnDraw event?? I am safe re-initialising my control as it does not change it''s state (unlike a web browser control for instance where the current web address would be lost on re-initiliasation), but is this a sensible thing to do or am I going to be shooting myself in the foot?? Cheers Colin


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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