Denaes Posted March 16, 2005 Posted March 16, 2005 I created a control, which is just nothing more than drawing and figuring sizes for a grid. I need this as a control because the grid will be much larger than the form and I need other controls all around on the form. So i figure to have this GridControl in the middle. Since I'm just drawing rectangles on it via GDI+, AutoScroll isn't working. I have to stick an actual control there... which I'm thinking of doing... maybe a picturebox with a picture to hold the grid "open" so it's scrollable. Yes, this is a real sad way of doing it. On the other side I'm thinking of just adding scrollbars and figuring out how to get the control to scroll with them... adding code to the controls resize that they only show up if the grid will be larger. Obviously if this can be done easier, I don't want to reinvent the wheel. Is there an easy solution I'm missing? Quote
*Experts* DiverDan Posted March 16, 2005 *Experts* Posted March 16, 2005 Why can't you draw the rectangles in a separate bitmap and use it as the panel's background image. Then set the AutoScroll properities to scroll the new image. Seems that this would be an easy solution....and that's why I often use this technique. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Denaes Posted March 17, 2005 Author Posted March 17, 2005 Well, the grid is contantly changing, might be 10x10 or 100x100 and I'll need to resize it at least to 50%, 100%, 150% and maybe 200% to accomidate different monitor sizes and user comfortability. I ended up going with 2 custom controls. One is just a rectangle with a black border (I might add further functionality to it at a later date) which is created as an array within another control which basically has all the setting options. This lets me change the size of the space between grid squares, grid square size, Grid Square colors individually and also easily check if someone clicked on a particular grid square and find grid squares easily. I wanted to have a 2d Array of these controls/classes within the GridContainer, but after 45 minutes of trying to create this array I just created a 1d array. This will really make performance worse as I have to keep cycling through the array checking X/Y values rather than just references the X/Y as the array indice Anywho, I'm sure that this can all be done via a picture and drawing on the picture, but it's beyond me at the moment. I seem to like the grid units being extensible and being able to add more features to each GridSquare. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.