CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    346

    GUI : Drawing a line on Dialog?

    I'm using VS 2005

    i want to draw a line on the dialog ,not from the code, but from the toolbox.
    isn't there a way to draw a line on the dialog by a control on the toolbox ?

  2. #2
    Join Date
    Mar 2006
    Location
    Graz, Austria
    Posts
    273

    Re: GUI : Drawing a line on Dialog?

    Nope. You have to draw the line programatically using System.Drawing
    Daniela
    ******
    I would love to change the world, but they won't give me the source code

  3. #3
    Join Date
    Aug 2004
    Posts
    346

    Re: GUI : Drawing a line on Dialog?

    thanks

  4. #4
    Join Date
    Oct 2001
    Posts
    80

    Re: GUI : Drawing a line on Dialog?

    There isn't a standard control, but you can easily create a UserControl to do that.

    1) Add a new UserControl to your project.
    2) In the onPaint eventhandler of the usercontrol put this code:
    Code:
        private void UserControl2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
          Graphics g = e.Graphics;
          Pen p = new Pen(Color.Black);
          int width = ClientRectangle.Width;
          int height= ClientRectangle.Height;
          g.DrawLine( p, 0, 0, width , 0 );
          p.Dispose();
        }
    3) Compile and use

    That might be handier when using multiple lines...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured