Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Datagrid and PictureBox drawing update, need some help.
 

Datagrid and PictureBox drawing update, need some help.

Hi,

One of my C# project include one gridview and one drawing (picturebox) on a form.
When the value in gridview change the drawing in the picture box drawing have to change and update instantly.
The drawing is simple X and Y horizontal and vertical mesh grid. (Idea is drawing the grid like picture by dataentry in gridview)
I need some advice and idea for that please.


Jimmy.
jimmy_yehtut  Thursday, October 23, 2008 3:09 AM

Hi jimmy_yehtut

You can handle the CellEndEdit event of DataGridView to get the new value of an edited cell. After that you can handle the Paint event of PictureBox and use Graphics.DrawLine to draw the graphics onto the PictureBox like this.

Code Snippet

pictureBox1_Paint(object sender, PaintEventArgs e)

{

Graphics g = e.Graphics;

Point p1 = new Point(�/span>// Decide on your entered value of DataGridViewCell

Point p2 = new Point(�/span>// Decide on your entered value of DataGridViewCell

g.DrawLine(new Pen(new SolidBrush(Color.Red)), p1, p2);

}

If you have any question, please tell me.

Sincerely,

Kira Qian

Kira Qian  Friday, October 24, 2008 7:24 AM

Hi jimmy_yehtut

You can handle the CellEndEdit event of DataGridView to get the new value of an edited cell. After that you can handle the Paint event of PictureBox and use Graphics.DrawLine to draw the graphics onto the PictureBox like this.

Code Snippet

pictureBox1_Paint(object sender, PaintEventArgs e)

{

Graphics g = e.Graphics;

Point p1 = new Point(�/span>// Decide on your entered value of DataGridViewCell

Point p2 = new Point(�/span>// Decide on your entered value of DataGridViewCell

g.DrawLine(new Pen(new SolidBrush(Color.Red)), p1, p2);

}

If you have any question, please tell me.

Sincerely,

Kira Qian

Kira Qian  Friday, October 24, 2008 7:24 AM

You can use google to search for other answers

Custom Search

More Threads

• TaskVision SourceCode VB W2k3 SERVER
• asgard2.0
• TaskVision as Document WorkFlow
• Is it possible to use the PhotoListView outside of this application?
• Converting Windows Application to DLL
• Xpander & chart control
• Inconsistent set of Dlls
• RAR / UNRAR
• Does Visual C# Express Work?
• How to Set Tooltip to Combobox Item at Binding Time in vb.net