|
Help Help!
I've created an array of small picturebox's on a form, and want them to highlight when I click on them, but I don't know how to let the event handler method know which picturebox (which member of the array) ive clicked on...
See code below:
private PictureBox[,] lifeForms;
public coverForm(int dimX, int dimY)
{
InitializeComponent();
lifeForms = new PictureBox[dimX, dimY];
for (int y = 0; y < dimY; y++)
{
for (int x = 0; x < dimX; x++)
{
this.lifeForms[x, y] = new System.Windows.Forms.PictureBox();
this.paper[x, y] = lifeForms[x, y].CreateGraphics();
this.Controls.Add(lifeForms[x, y]);
lifeForms[x, y].BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
lifeForms[x, y].Location = new System.Drawing.Point((x*20)+4, y*20+4);
lifeForms[x, y].SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
lifeForms[x, y].Size = new System.Drawing.Size(20, 20);
lifeForms[x, y].Show();
lifeForms[x,y].MouseClick += new MouseEventHandler(this.selectDim_Click);
}
}
}
private void selectDim_Click(object sender, EventArgs e)
{
How can I read which picture box the user has clicked on down here?!!
}
Mark.
|
|
|
|
|
Hello,
The sender object is the instance of the pictureBox you whant.
You just have to cast it.
PictureBox actBox = sender as PictureBox
if(actBox!=null)
{
}
Hope it helps,
Martin
|
|
|
|
|
Thanks heaps guys I've got it working now... Legendary!!!
Mark.
|
|
|
|
|
You can assign tag to each picturebox and then find out which one was clicked by examining sender
|
|
|
|
|
Hello,
It's not neccessary to iterate threw the collection to find and compare the tag, and then find a member which is already passed by the event itselfe!
All the best,
Martin
|
|
|
|
|
You won't have to iterate through all the collection you just cast sender to picturebox and then examine its tag to see which one is it.
|
|
|
|
|
Sorry missunderstood your answer!
Giorgi Dalakishvili wrote: just cast sender to picturebox
That's what I answered before.
Giorgi Dalakishvili wrote: and then examine its tag to see which one is it
Why would you have to use a tag if you have the instance itselfe?
All the best,
Martin
|
|
|
|
|
If you are doing the same thing for every picturebox then you don't need but if it depends on which picturebox it is then you will need to examine tag. In this question I think only highlighting is needed and in that case you don't need but he also asked how to find out which picturebox was clicked. So if he is interested in which picturebox is the sender then he will need.
|
|
|
|
|
this problem is the ocx control must used in multiForm(LoginForm,MainForm...). But these forms must Call only one that the ocx instance .
Please give me a good scheme for solving this Problem with C#.
Thanks.
|
|
|
|
|
I have a problem, hope someone can help me:
I have 2 computer conected by LAN. I want run a program(ex: Notepad) on Computer B from computer A.But I can't find any function to do that.
Anyone can solve that problem, help me please!
Thank a lots!
|
|
|
|
|
I really don't know what this question
is doing in a programming discussion board.
However, use this programm.
http://www.realvnc.com/
Greetings
pdluke
|
|
|
|
|
I think he wants to do it through code, as this is a programming discussion board...
I made a program that does this sort of thing. What I did is made a windows service for my clients, although a client application would work too. Then I made a server application that would tell the client what program to start.
The client windows service would invoke the start of the program.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Oh thanks for the reply.
I didn't even think to use a service for so a "trivial" thing.
I often use WCF-Services by my self, but these are for some bigger projects.
sorry, that misunderstood the question
|
|
|
|
|
Well I needed to use a service because the computers I needed the service on were headless servers. They needed to be able to always be waiting for the queue to run the passed program.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Sorry, double post
|
|
|
|
|
"urgent" what are you expecting?? a full functioning code??
try reading through socket programming articles, that will be a good start.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
I am using Visual Studio 2005 and C# to develop a windows application. I have a UserControl that various input forms (textboxes). On my windows form I have a Panel with AutoScroll = true.
I add the UserControls at runtime. They are all added under each other and I determine the Y position on the Panel and then add the next UserControl to Panel as follows:
private int verticalGap = 5;<br />
private int yLocation = 1;<br />
<br />
yLocation += userControl1.Size.Height + userControl1.Location.Y + verticalGap;<br />
userControl1.Location = new Point(1, yLocation );<br />
panelEntries.Controls.Add(userControl1);
The UserControls are all added to Panel and all display as required under each other. However once I have scrolled down to see the UserControls at the bottom of the Panel, and I add more UserControls they do not seem to adhere to the verticalGap value I use in my formula because the gap between the last UserControl and the previous one is now suddenly much more than it should be.
When I add the new UserControl using the Point coordinates, does it use only the visible part of the Panel to determine the position rather than using the full sizes of the Panel?
Any ideas of how I can remedy this?
Kobus
|
|
|
|
|
Maybe you can reset the whole control and add all the controls again, then move back to the position the user was, although that doesn't seem like the right way...
I would see if the methods you are using are using relative or fixed point locations. Meaning when you scroll down do the points move up or just refer to a different 'spot', if that makes sense.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
hi,
i had the same problem a year back where i had to add controls that displayed pictures to a scrollable panel. it seems that it uses the visible part, so, when i scrolled while the controls were being added by a background thread, y-coordinate seemed to change.
one way i got around it was to disable the panel when the controls were being added and enabling it when the adding was complete.
regards
|
|
|
|
|
In Vs 2003 is embeded crystal report version 9
But I installed Crystall report version 11 in my computer
So dll file for Crystal report for Vs2003 is changed and affected my project occured error.
Please give me advice.
How can I recovery crystal report version 9 to Vs2003 and not affected to Crystal report version 11.
|
|
|
|
|
My project is Windows base.
So It's difficult to update newer version system because I have to install every computers of customer's site ( Some computer located on third floor, second floor and ground floor )
So I wish to make installer which set-up pass through network.
Please give me any idea or advice for complete this Idea....
|
|
|
|
|
If you have access to servers and are allowed to modify and install services on those servers you can use RIS.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
My report size is A3. When I export to .rtf or .doc it can't display correct. Can I set paper size before export?
Code:
...
ExportOptions crExportOptions = crReportDocument.ExportOptions;
crExportOptions.ExportFormatType = ExportFormatType.RichText;
crReportDocument.Export();
QuynhTD
-- modified at 23:31 Monday 21st May, 2007
|
|
|
|
|
You just have to right click on report format --> Design --> Page Setup --> Page option --> Select The format of your choice.
|
|
|
|
|
Hello everyone,
I have a DataGridView which I am populating it with a data from a remote database. One of the columns in the DataGridView is holding images. I would like to know if it is possible to display the image in the DataGridView in a ImageBox using the index of the row?
Thank you very much and have a great day.
Khoramdin
|
|
|
|