473,595 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw lines C#

2 New Member

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
  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);
thanks in advance.
May 20 '07 #1
4 9193
4,871 Recognized Expert Specialist
Is there any event is triggered by maximizing the program?
May 20 '07 #2
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
211 Recognized Expert New Member
try to refresh your panel

May 20 '07 #4
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;
  9. namespace TryDraw
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.         }
  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. }
May 21 '07 #5

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

Similar topics

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
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
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
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...
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!
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
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);
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
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)
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...
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,...
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...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.