Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button , my wish is to add a new small picturebox on the map_picture and the new added picturebox should have click event to get the location of it when it is clicked.
i have written some code in C# but when clicking the small picturebox it just gets the location of the last added one, not the one that i clicked on .
here is my code:
pic_map: main picturebox
i global int, initial value=0 -
private void pic_map_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
-
{
-
x=e.X;
-
y=e.Y;
-
if((e.Button==MouseButtons.Left)&&(tag==1))
-
{
-
i=i+1;
-
musteri=new Bitmap("f:musteri_button.jpg");
-
// node[j]=new PictureBox();
-
// node[j].Image=musteri;
-
}
4 3819
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named btn_customer to my form, my wish is to add new small picturebox to the coordinates that the user click on the pic_map and the new added picturebox should have click event to get the location of it when it is clicked and also be a member of the picturebox array.
after clicking the btn_customer, the coordinate thet user click on the pic_map there should be added a new picturebox with a tag number increasing 1 every time.
i have written some code in C# but when clicking one of the small picturebox it just gets the location of the last added one, not the one that i clicked on .
here is my code: - pic_map: main picturebox
-
-
i global int, initial value=0
-
-
musteri=new Bitmap("f:musteri_button.jpg");
-
PictureBox [] node; //global
-
-
private void pic_map_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
-
{
-
x=e.X;
-
y=e.Y;
-
node=new PictureBox[50];
-
if((e.Button==MouseButtons.Left)&&(tag==1))
-
{
-
i=i+1;
-
node[j]=new PictureBox();
-
node[j].Image=musteri;
-
node[i].Size=new System.Drawing.Size(36,26);
-
node[i].Location=new System.Drawing.Point(x,y);
-
node[i].Visible=true;
-
node[i].Name="node"+i;
-
node[i].Click += new System.EventHandler(this.node_Click);
-
node[i].Tag=i;
-
this.pic_map.Controls.Add(node[i]);
-
}
-
private void btn_customer_Click(object sender, System.EventArgs e)
-
{
-
tag=1;
-
}
-
-
private void node_Click(object sender, EventArgs e)
-
{
-
int a,b;
-
a=node[Convert.ToUInt32(((PictureBox)sender).Tag)].Location.X;
-
b=node[Convert.ToUInt32(((PictureBox)sender).Tag)].Location.Y;
-
}
Please help me, thanks for your consider....
An if statement runs only once and you want to run a loop. HTH.
Plater 7,872
Recognized Expert Expert
Couldn't u assign a mouse click event to the picturebox itself?
An if statement runs only once and you want to run a loop. HTH.
Thanks, i have tried to use a loop, but could'nt find a way to get the clicked location while in the loop, if i define the x, y coordinate by manuel it works, but it does'nt allow getting the coordinates from picturebox while looping, or i could'nt find a way...
if you have an idea please confirm, thanks again
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tim Bücker |
last post by:
Hello.
I want to render in a picturebox (pbD3DSurface) using DirectDraw. This is
working more or less but the coordinates are always screen oriented and not
pictureBox oriented.
x = 10; //+this.Location.X+this.pbD3DSurface.Location.X;
y = 10; //+this.pbD3DSurface.Location.Y+this.Location.Y;
back.DrawCircle(x, y, 5); //back = surface
|
by: akh |
last post by:
I want to use de Drag and Drop ´s event to move a picture box from a
form and within a Picture Box.
But I have behaviour if the MyPBox As PictureBox as the Globale
varible or not
Thanks for your help,
Here is the code.
|
by: Christopher Kurtis Koeber |
last post by:
Dear All,
This may sound like an elementary question but how do you implement
scrollbars for the Picturebox control. Do I have to create my own code to do
this or is there some property that I can set? Thank you very much for your
time and consideration in this matter!
Christopher Koeber
|
by: kalp suth via DotNetMonster.com |
last post by:
I want to create arrows using lines on a picture in the picture box.
On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the actual drawing work.
But after displaying all the arrows in a flick, the arrows disappers.
I have debugged and came to know that the "Paint" event of the picturebox is refreshing the image, so the work done on the CreateGraphics created object is...
|
by: Tom |
last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to
stretched. I then load an image into that form and display it. As the user
moves the mouse over the form, I want to get and display (in the status bar)
the image coordinates of the mouse location. However, if I use the
picturebox's MouseMove event, I am getting the coordinates of the mouse over
the PICTUREBOX, not the actual image underneath that (which is stretched)....
| |
by: toby |
last post by:
Hi there,
Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)
|
by: Steven Garrad |
last post by:
Hi All,
I have a pictureBox control inside of a panel control. The pictureBox is
larger than the panel control and I have the panel control set true for
AutoScroll so the panel displays scrolling bars.
I would like the user to be able to click and drag the image and for it to
move around within the panel control.
How would I do this?
|
by: Jim McGivney |
last post by:
In C# on Form1 I genetate an array of PictureBoxes and populate each with an
image as seen in the code below.
Later on I want to access a specific PictureBox to change its image, but I
keep getting the error "The name 'PictureBox1' does not exist in the current
context"
The code I use to try to access the PictureBox is "PictureBox1.Image
= HoldBitMap; " where kount is an integer.
I know the answer is probably in using the Controls...
|
by: AWW |
last post by:
XP VB 2005 running an example from help that creates a picturebox in
code - the picturebox is not created.
If I comment out the "Dim Box as New PictureBox" and create it in
Design mode - the example works.
I have tried Show, Enabled, Visible, and even BackColor.
Why does a help example not work? and why does Design creation work?
Thanks - I hope.
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |