473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Draw lines C#

HI

I'm very new to C# and I've got a big project to do in C# for uni until july.

I've been trying do draw lines in C# (arrows to be precise). I can draw them allright but once I minimize the program and maximize it again, the arrows dissapear :S.
this also happens if I open another program on top of the program I'm creating.
Is their a way to correct this?

To draw the lines I've been using this piece of code.
Expand|Select|Wrap|Line Numbers
  1.  
  2.  Graphics graph =  panel1.CreateGraphics();  
  3.  Pen pencurrent = new Pen(Color.Black);  
  4.  graph.DrawLine(pencurrent, 220, ultimoponto, 220, ultimoponto+20);
  5.  graph.DrawLine(pencurrent, 215, ultimoponto + 15, 220, ultimoponto+20);
  6.  graph.DrawLine(pencurrent, 225, ultimoponto + 15, 220, ultimoponto+20);
  7.  
thanks in advance.
May 20 '07 #1
4 9182
kenobewan
4,871 Expert 4TB
Is there any event is triggered by maximizing the program?
May 20 '07 #2
nope. no events.
The minimzing and maximizing was an example. this also happens if I move another window on top of the arrow. (I'm not sure if I'm making myself clear). When the arrow is hidden due to the program being minimized, or due to being hidden by another window, it simply dissapears.
May 20 '07 #3
vanc
211 Expert 100+
try to refresh your panel

cheers.
May 20 '07 #4
shidec
26
Put ur program at OnPaint event of the panel,
so every time its need to redraw it will do.

Try to find graphic/animation program in c#,
they always override OnPaint method on a class.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace TryDraw
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.  
  18.         private void panel1_Paint(object sender, PaintEventArgs e)
  19.         {
  20.             int ultimoponto = 100;
  21.             Pen pencurrent = new Pen(Color.Black); 
  22.             e.Graphics.DrawLine(pencurrent, 220, ultimoponto, 220, ultimoponto+20);
  23.             e.Graphics.DrawLine(pencurrent, 215, ultimoponto + 15, 220, ultimoponto + 20);
  24.             e.Graphics.DrawLine(pencurrent, 225, ultimoponto + 15, 220, ultimoponto + 20);
  25.         }
  26.     }
  27. }
  28.  
May 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: taccea | last post by:
I need to print a report, but I need to first draw lines and boxes for the data. I need to do it at print time using VBA. How do I do this? Any suggestions appreciated. Taccea
0
by: JDeats | last post by:
Is it possible to use GDI+ to draw: lines, points, shapes, etc... inside a RichTextBox? It seems VS.NET does this with the code edit window (left margin code collapse/expand boxes)? Best, Jeremy
1
by: prakash437 | last post by:
Hello everyone .. Can any of you please tell me how to draw lines joining two points in a page using PHP. Not on an image but on the page itself?? And the lines also need to be at an angle to the...
9
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a...
1
by: weberwhennner | last post by:
Hi All, Since two days Ive been trying to draw lines and polygons interactively (using mouse clicks), but all ive found is some libraries that draw shapes using predefined cooredinates. Ive...
6
by: Nirosh | last post by:
Hi All, http://www.tourneylogic.com/Products/BracketControl/Demos/V2/PopularTourneys/NCAA.aspx Can some one tell me how he has draw lines here.. is it a trick done using DIV/ CSS or using the...
0
by: Anuhas | last post by:
Dear Experts, I need to draw lines. But I have to make a class for this. I know how to draw lines in direct methods. i.e. Graphics g =...
0
by: krantik | last post by:
i need to draw lines like grid lines between images in a list control.i have used LVS_EX_GRIDLINES but its only working in report view .i need it in thumbnail view
2
by: aznimah | last post by:
Hi, i need help on draw lines from vertices (vertex points that i stored the values in arraylist. i already done the vertex points of shape and now my problem is to draw line between those...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.