Click here to Skip to main content
13,452,262 members (56,367 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to create tiles grid background in gdi+ where i can draw shapes or do other stuff on would be my application 's surface design and and use scrolling feature ??????? As I am new to GDI+ so kindly gives some guideline

i have have created this function now i want to set this design as background screen
private void DrawCaroBoard(Graphics graphics, int row, int col, int width)
            //Draw background
            var linearBrush = new LinearGradientBrush(new Rectangle(_startPoint.X, _startPoint.Y, col * width, row * width), Color.Turquoise,
                Color.White, LinearGradientMode.BackwardDiagonal);
            graphics.FillRectangle(linearBrush, _startPoint.X, _startPoint.Y, col * width, row * width);

            //Draw rows
            for (var i = 0; i <= row; i++)
                graphics.DrawLine(new Pen(Brushes.DarkTurquoise, 2), _startPoint.X, _startPoint.Y + i * width, _startPoint.X + col * width, _startPoint.Y + i * width);

            //Draw columns
            for (var j = 0; j <= col; j++)
                graphics.DrawLine(new Pen(Brushes.DarkTurquoise, 2), _startPoint.X + j * width, _startPoint.Y, _startPoint.X + j * width, _startPoint.Y + row * width);

now how to use this function in my form to its background ???
Posted 30-Sep-12 9:31am
Updated 30-Sep-12 10:42am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

For a form graphics rendering, override the method OnPaint and call your rendering method in it:
protected void OnPaint(PaintEventArgs e) {
   int row = // ???
   int column = // ???
   int width = // I have no idea how you calculate those, but this is something 
               // depending on the state of the form -- you should know better
   DrawCaroBoard(e.Graphics, row, column, width);

Please see[^].

Now, scrolling. Pay attention that the class System.Windows.Forms.Form is derived from the class System.Windows.Forms.ScrollableControl, so scrolling is already created for you. As Panel also inherits the properties and behavior of this class, you can scroll its content the same way. Please see:[^].

The idea is to use AutoScroll and AutoScrollMinSize. When the actual size becomes less then "auto", vertically or horizontally, the appropriate scroll bar appears (or both), helping to scroll the control's content to show the whole content which is assumed to be of the minimal size.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180318.3 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100