Graphical net and text

Posted by chesheerkys on Stack Overflow See other posts from Stack Overflow or by chesheerkys
Published on 2010-04-28T01:02:00Z Indexed on 2010/04/28 1:03 UTC
Read the original article Hit count: 390

Filed under:
|
|
|
|

Hello!

My task is to make a control, that behaves itself like RichTextBox, but contains a graphical net. The only task, this net is solving, is to be visible.

It should be solution in overriding OnPaint method, but it doesn't.

This code:

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    base.OnPaint(e);
    ...//drawing a line
}

gives me RichTextBox without of text

This code:

protected override void WndProc(ref System.Windows.Forms.Message m)
{
    base.WndProc(ref m);
        if (m.Msg == 15)
        {
            Graphics g = this.CreateGraphics();
            g.DrawLine(new Pen(Color.White, 1), new Point(0, 0), new Point(400, 400));
        }
}

sometimes draws extra lines

Actually since these two ways don't work, I don't know what to try. Waiting for your advices :)

BR Dmitry

P.S. I’ve heard a lot about great opportunities of WPF, but I’m not really common with this technology and don’t know what to start with. P.P.S. Sorry for my English, it’s not my natural language.

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows.forms