Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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..

Visit: VBSourceSeek - The VB.NET sourcecode library

 

 

"A mere friend will agree with you, but a real friend will argue."
Posted
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

There is no spoon. <<The Matrix>>
Posted

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; 
           }
       }
   }
}

Posted
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.

rustyd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...