TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jonas Baltrusaitis
NA
9
5.7k
click button event problem
Feb 16 2011 7:49 PM
I want to do a simple thing: create windows form with a button and get line drawn when I click button. So far no luck with button click event, e.g. how do I make that line be drawn via private void button1_Click(object sender, EventArgs e)?
Is there a more appropriate beginners forum or I can post here?
thanks
Jonas
namespace Example1_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.BackColor = Color.White;
}
public void OnPaint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Inch;
Pen blackPen = new Pen(Color.Black, 5 / g.DpiX);
g.DrawLine(blackPen, 0, 0, 1, 1);
}
private void button1_Click(object sender, EventArgs e)
{
Application.Run(new Onpaint());
}
}
}
Reply
Answers (
7
)
windows forms
sorting in gridview