how to change the style of Grid lines.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thanawala27
    New Member
    • Mar 2007
    • 68

    how to change the style of Grid lines.

    Hi, I wanted to change the style, width and color of the grid lines for my X/Y scatter graph.

    Basically, I want to distinguish the minor grid lines and the major grid lines.

    Any help is appreciated.


    Thanks,

    Ravi
  • Limno
    New Member
    • Apr 2008
    • 92

    #2
    Test this code, I ll work....


    using System;

    using System.Collecti ons.Generic;

    using System.Componen tModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows. Forms;



    namespace Sample2

    {

    public partial class GroupBoxTest : Form

    {

    public GroupBoxTest()

    {

    InitializeCompo nent();

    }



    private void GroupBoxTest_Lo ad(object sender, EventArgs e)

    {

    myGroupBox myGroupBox = new myGroupBox();

    myGroupBox.Text = "GroupBox1" ;

    myGroupBox.Bord erColor = Color.Red;

    this.Controls.A dd(myGroupBox);

    }

    }



    public class myGroupBox : GroupBox

    {

    private Color borderColor;



    public Color BorderColor

    {

    get { return this.borderColo r; }

    set { this.borderColo r = value; }

    }



    public myGroupBox()

    {

    this.borderColo r = Color.Black;

    }



    protected override void OnPaint(PaintEv entArgs e)

    {

    Size tSize = TextRenderer.Me asureText(this. Text, this.Font);



    Rectangle borderRect = e.ClipRectangle ;

    borderRect.Y += tSize.Height / 2;

    borderRect.Heig ht -= tSize.Height / 2;

    ControlPaint.Dr awBorder(e.Grap hics, borderRect, this.borderColo r, ButtonBorderSty le.Solid);



    Rectangle textRect = e.ClipRectangle ;

    textRect.X += 6;

    textRect.Width = tSize.Width;

    textRect.Height = tSize.Height;

    e.Graphics.Fill Rectangle(new SolidBrush(this .BackColor), textRect);

    e.Graphics.Draw String(this.Tex t, this.Font, new SolidBrush(this .ForeColor), textRect);

    }

    }

    }



    Originally posted by thanawala27
    Hi, I wanted to change the style, width and color of the grid lines for my X/Y scatter graph.

    Basically, I want to distinguish the minor grid lines and the major grid lines.

    Any help is appreciated.


    Thanks,

    Ravi

    Comment

    Working...