stustarz Posted May 26, 2005 Posted May 26, 2005 Easiest and quickest way is to add a label control to your form, set its height to 1 or 2 pixels and then the width to however long you want it. By setting the borderstyle to 3D (but change it until you see the desired effect) you can have a line that looks just like that. Alternatively create a custom control which you could then use to apply different line effects such as dashes, dotted lines etc.. Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
Wile Posted May 26, 2005 Posted May 26, 2005 How about http://www.codeproject.com/cs/miscctrl/NiceLine.asp or http://www.codeproject.com/cs/miscctrl/officeline.asp Quote Nothing is as illusive as 'the last bug'.
Leaders snarfblam Posted May 26, 2005 Leaders Posted May 26, 2005 That 3D 2-pixel label is pretty nifty (for a quick&dirty solution). Quote [sIGPIC]e[/sIGPIC]
michael_hk Posted May 27, 2005 Posted May 27, 2005 Easiest and quickest way is to add a label control to your form, set its height to 1 or 2 pixels and then the width to however long you want it. By setting the borderstyle to 3D (but change it until you see the desired effect) you can have a line that looks just like that. I like this solution. :p Quote There is no spoon. <<The Matrix>>
MadHatter Posted May 30, 2005 Posted May 30, 2005 here's a quick and dirty line control I wrote a long time ago. feel free to use it. /* * Copyright © 2003 NullFX Software * By: Steve Whitley * * $Log: Line.cs,v $ * * */ namespace NullFX.Controls { using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; [Designer(typeof(Line.LineDesigner))] public class Line : System.Windows.Forms.Control { internal class LineDesigner : System.Windows.Forms.Design.ControlDesigner { public override System.Windows.Forms.Design.SelectionRules SelectionRules { get { return System.Windows.Forms.Design.SelectionRules.LeftSizeable | System.Windows.Forms.Design.SelectionRules.RightSizeable | System.Windows.Forms.Design.SelectionRules.Visible | System.Windows.Forms.Design.SelectionRules.Moveable; } } } private System.Windows.Forms.FlatStyle _flatStyle; private Pen _systemPen; private System.ComponentModel.Container components = null; [Category("Appearance"), Description("Determines the display of the control when the users move the mouse over the control and click")] public System.Windows.Forms.FlatStyle FlatStyle { get{return _flatStyle;} set{ _flatStyle = value; Invalidate(); } } public Line() { _flatStyle = FlatStyle.Standard; _systemPen = new Pen(SystemColors.ControlDark, 2); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer| ControlStyles.ResizeRedraw| ControlStyles.UserPaint, true); } protected override void Dispose( bool disposing ) { if( disposing ) { if( components != null ) { components.Dispose(); } } base.Dispose( disposing ); } protected override Size DefaultSize { get { return new System.Drawing.Size(32, 2); } } protected override void OnPaint(PaintEventArgs pe) { switch(_flatStyle) { case System.Windows.Forms.FlatStyle.Flat: case System.Windows.Forms.FlatStyle.Popup: case System.Windows.Forms.FlatStyle.Standard: { pe.Graphics.FillRectangle(SystemBrushes.ControlLightLight, 0, 0, Width, 2); pe.Graphics.FillRectangle(SystemBrushes.ControlDark, 0, 0, Width - 1, Height / 2); }break; case System.Windows.Forms.FlatStyle.System: { pe.Graphics.DrawLine(_systemPen, 0, 1, Width, 1); }break; default: goto case System.Windows.Forms.FlatStyle.Standard; } } } } Quote
rustyd Posted June 1, 2005 Posted June 1, 2005 can i make a line like this? thx :) The lines are from a groupbox inside another control (a panel or another groupbox). The location left setting is less than the container control and the size width is greater than the width of the container control. Quote rustyd
Leaders snarfblam Posted June 1, 2005 Leaders Posted June 1, 2005 Cerainly works. I like the label better though. It's... smaller. Quote [sIGPIC]e[/sIGPIC]
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.