By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

how to change the style of Grid lines.

P: 68
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
May 5 '09 #1
Share this Question
Share on Google+
1 Reply


P: 92
Test this code, I ll work....


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;



namespace Sample2

{

public partial class GroupBoxTest : Form

{

public GroupBoxTest()

{

InitializeComponent();

}



private void GroupBoxTest_Load(object sender, EventArgs e)

{

myGroupBox myGroupBox = new myGroupBox();

myGroupBox.Text = "GroupBox1";

myGroupBox.BorderColor = Color.Red;

this.Controls.Add(myGroupBox);

}

}



public class myGroupBox : GroupBox

{

private Color borderColor;



public Color BorderColor

{

get { return this.borderColor; }

set { this.borderColor = value; }

}



public myGroupBox()

{

this.borderColor = Color.Black;

}



protected override void OnPaint(PaintEventArgs e)

{

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



Rectangle borderRect = e.ClipRectangle;

borderRect.Y += tSize.Height / 2;

borderRect.Height -= tSize.Height / 2;

ControlPaint.DrawBorder(e.Graphics, borderRect, this.borderColor, ButtonBorderStyle.Solid);



Rectangle textRect = e.ClipRectangle;

textRect.X += 6;

textRect.Width = tSize.Width;

textRect.Height = tSize.Height;

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

e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), textRect);

}

}

}



@thanawala27
May 29 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.