473,756 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw lines C#

2 New Member
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 9205
kenobewan
4,871 Recognized Expert Specialist
Is there any event is triggered by maximizing the program?
May 20 '07 #2
hastalavista
2 New Member
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 Recognized Expert New Member
try to refresh your panel

cheers.
May 20 '07 #4
shidec
26 New Member
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
1664
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
1676
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
1559
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 horizontal. Thanks, Vaddina Prakash Rao
9
4027
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 reference to a control or a form. I guess it means that lines can't be draw on blank area between two forms. Can anybody guarantee this for me? Is there any method can realize this function? I mainly want to draw a line from a button in form1 to...
1
2642
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 also been trying to search for books on amazon that would help me learn more about this, but looks like I'm not using the right search terms... Any pointers, examples or related links would be greatly appreciated. Thanks a lot!
6
4061
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 graphic lib.. I also have asked to develop some thing similar.. I have some idea about how to go about here.. but performance wise and also cross browser compliancy wise I have some concerns.. can some one shoot couple of hints for me to
0
966
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 = this.CreateGraphics(); Pen mypen = new Pen(Color.Red, 2); mypen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; g.DrawLine(mypen, 100, 100, 200, 300);
0
1087
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
2833
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 vertices i need to draw geometry connected lines example: -Diamond- i already have the vertex values (which 4 points in x, y position) -i get the values from the arraylist (stored)
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.