hi,
i used panel1,panel2 on form2
for eg i have slected panel1 color is red
panel2 click event
System.Drawing.Graphics graphicsObj;
graphicsObj = panel2.CreateGraphics();
Pen graphPen = new Pen(panel1.BackColor, 15);
graphicsObj.DrawLine(graphPen, 5, 10, 120, 10);
now if click on panel2 show draw line panel1 selected red color
this is ok,
but i want to show form2 panel2 drawline color (i.e red) to form1 datagridview column0 row0
plz help me the code?
Loading
cad sunnyPosted Oct 6, 2014, 2:39 AM
anybody help us.
thanks in advance
cad sunnyPosted Sep 30, 2014, 2:44 AM
if i right click on datagridview cell form2 is open.i selected color using right click on panel1 eg.red color.then i click on panel2 panel1 color is shown panel2 red color(panel2 iam using paint and click event graphics Drawline method
after this if i click Add to form1 button click it shold be shown panel2 DrawLine red color show to form1 datagridview cell.
also i attached my project file also.plz ref and help us.
Selva GanapathyPosted Sep 29, 2014, 10:34 AM
Hi Cad Sunny,
You have to pass the color to Form2 from Form 1 (or the object you need) as per the following code. And the blog may help you in a better way
http://www.c-sharpcorner.com/UploadFile/6f0898/simple-way-to-establish-interaction-between-two-from-inside/
public Form2(Color color)
{
InitializeComponent();
colorFromFrom1 = color;
}
Color colorFromFrom1;
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = this.panel2.CreateGraphics();
Pen graphPen = new Pen(colorFromFrom1, 15);
graphicsObj.DrawLine(graphPen, 5, 10, 120, 10);
}
private void button2_Click(object sender, EventArgs e)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = this.panel2.CreateGraphics();
Pen graphPen = new Pen(this.panel1.BackColor, 15);
graphicsObj.DrawLine(graphPen, 5, 10, 120, 10);
}
Regards,
Selva Ganapathy K