I want to draw rectangles and lines on panel (c#),but i want to draw like in proper layout.
First thing is there is possibility to draw on flowLayoutPanel(c#).
because i want to draw in proper lines and columns.
if not then is there any other way to do this?
Thanks in advance :)
praveen mishraPosted Sep 27, 2012, 7:08 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int y;
int x;
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
Point p = new Point(e.Y, e.X);
x = p.X;
y = p.Y;
panel1.Invalidate();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = panel1.CreateGraphics();
Pen p = new Pen(Color.Black);
if (listBox1.SelectedIndex == 0)
{
SolidBrush sb = new SolidBrush(Color.Red);
g.DrawEllipse(p, x - 50, y - 50, 100, 100);
g.FillEllipse(sb, x - 50, y - 50, 100, 100);
}
if (listBox1.SelectedIndex == 1)
{
SolidBrush sb = new SolidBrush(Color.Red);
g.DrawRectangle(p, x - 50, y - 50, 100, 100);
g.FillRectangle(sb, x - 50, y - 50, 100, 100);
}
}
}
}