|
ExpertComing wrote:
private void map11_Click(object sender, System.EventArgs e)
{
object snd = (ComboBox)cmbLevel.SelectedItem;
ChangePicture(snd);
}
Change the ChangePicture call to ChangePicture(sender, e); . BTW, what is in the combo box? You would bind every picture box to this handler, to this particular routine is called when the user clicks on *any* picture box.
ExpertComing wrote:
private void ChangePicture(object sender, System.EventArgs e, object snd)
{
// Display an OpenFileDialog so the user can select a Cursor.
Remove the third parameter in the definition so you have:
private void ChangePicture(object sender, System.EventArgs e) and see my other replies.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
The envent handler has two parameters: Object sender and EventArgs e . The first represents the object that raised the event. In this case, if you have several objects attached to the same event handler, you should use this parameter to distinguish.
Say you have 3 pictures boxes: pictureBox1 , pictureBox2 and pictureBox3 . You set the event handlers like this:
pictureBox1.Click += new EventHandler(pictureBox_Click);
pictureBox2.Click += new EventHandler(pictureBox_Click);
pictureBox3.Click += new EventHandler(pictureBox_Click); Then you only have one event handler:
private void pictureBox_Click(object sender, EventArgs e)
{
OpenFileDialog openDialog = new OpenFileDialog()
....
Image image = Image.FromFile(openDialog.FileName);
((PictureBox) sender).Image = image;
} I hope this explains it better.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I got the coding part done before you replied again lol.
But now I get this error.
No overload for method 'ChangePicture' takes '0' arguments
|
|
|
|
|
GOT IT SWEET!
Thanks for the help.
|
|
|
|
|
You're welcome! great it worked!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I have to fix a weird problem where a file needs to be moved using File.Move from a local directory to a network drive. The code that I'm trying to fix tries to pass either a network path or a mapped network drive path as a parameter to the Directory.Exists method but it fails. This code runs as a Windows service under XP.
I wrote my own exe to do the same thing but my code works. Why would an EXE work and not the service? Permissions to both drives are for Everyone.
Help.
|
|
|
|
|
Because the service in running under the Local System account (by default) which doesn't have rights to anything on the network. That's why the code works when YOU run it. It's running under your account.
You have to go into the Service Manager and change the account the service in running under to one with rights to the network.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hmmm... I already changed the service to run under my log on from the services' Properties Log On dialog and also changed the ownership of the mapped network drive to my name as well.
Is there another place where I need to change the log on?
|
|
|
|
|
Check on the two issues:
(*) The default path that gets formed for destination/source files. I think it would form as %system%, unless you prefix and qualify with AppDomain.CurrentDomain.BaseDirectory to get the proper path.
(*) RunAs of the EXE to run with an account with network access to the target resource.
Deepak Kumar Vasudevan
Personal Web: http://vdeepakkumar.netfirms.com/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
"Mapped network drive"? Hmmmm.... Sounds like the login isn't running the login script to map the drive. Not surprising actually.
Try using UNC names instead, like \\server\volume\path\filename. This will remove your codes dependancy on a legal login script running.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I made a chat program and I used a ListBox for the display. The problem is that when it becomes to large and the vertical scroll bar appears, when someone types a message, it doesn't show. You have to manually scroll for the latest item to appear on the screen.
Help would me much appreciated
|
|
|
|
|
There is a setselection property or similar you can use to set which text is selected in the listbox. If you go to msdn.microsoft.com and search for ListBox, you can get documentation on all the methods of the control, and what they do.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The thing is I don't want anything to be selected. The only way I managed to solve the problem was if just after I typed something in the ListBox, I selected and then deselected the last item. Then the scroll would slide down to the bottom. But I'm sure there is a more elegant solution
|
|
|
|
|
That's fine, you can select the position one past the last character. I remember doing this once before.
|
|
|
|
|
Hello everyone!
OK, just a question now... I made a music program that has a ListBox with a music note in each item. When the music plays, the selected note in the ListBox changes according to which note is playing, but there's a problem... When the playing note reaches the bottom of the ListBox, it pauses for a second to go down... How can I fix this? Thanks!
Darth_Sulfur (Sulfurik)
http://www.SulfurSoft.tk
ftp://tsfc.ath.cx
http://tsfc.ath.cx
hotline://tsfc.ath.cx
|
|
|
|
|
Can someone provide a 'Foo' type example to explain a shallow and deep copy.
I've read so many explanations that seem to contradict each other that I'm lost. "objects referenced" part of most definitions is what is troubling me..
thanks....
|
|
|
|
|
It's pretty simple actually. A shallow copy is when you copy just the references to an object, a deep copy copies the objects themselves. For example
class Foo
{
}
class Bar
{
Foo f;
public Bar ShallowCopy()
{
Bar b = new Bar();
b.f = this.f;
return b;
}
public Bar DeepCopy()
{
Bar b = new Bar();
b.f = f.DeepCopy();
return b;
}
}
The Bar object returned by ShallowCopy and the original Bar object both have the same reference to the Foo object. DeepCopy, as you can see, copies the Foo object itself. Note that if Foo has references to some other objects, then it needs to DeepCopy those also and so on. Basically, DeepCopy recursively copies the entire object graph.
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
I did know about MemberwiseClone, I deliberately wrote it that way because I thought it explained shallow copying better.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have created three windows services in which two services listening two different logical ports continously and one service capture COM ports. These windows services informs the Main Window Application which is also running in different Application Domain or Window Process space. These services and windows application is created in C# .NET
My Question is that which is the best way to communicate between these Windows Services running on the same machine (locally).
1. DOT NET Remoting Services
2. Message Queues
3. Through Socket
4. Through Database
Reliability and scalibility is the main requirement because this machine act as a server and traffic is very high.
Your co-operation would be highly appreciated.
Thanks
Zeeshan
|
|
|
|
|
I have a ListView Control and I make its width bigger in Resize() Event...
when it get bigger, it gets over the space of my program has before Resizing.
And the last column has broken of its right that over the line of newly added space of my program.
right side of last column is cutted and thown away. but the detailed item is shown precise.
I tried varous value for columnHeader3.Width but it broken again and again.
Of course, I don't mistake the order of resizing the listView and the panel that has it.
Please give me a hand for the solution.
InitializeComponent()......
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.listView1.Alignment = System.Windows.Forms.ListViewAlignment.Default;
this.listView1.BackColor = System.Drawing.Color.Gainsboro;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,this.columnHeader2,this.columnHeader3});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(4, 120);
this.listView1.Name = "listView1";
this.listView1.Scrollable = false;
this.listView1.Size = new System.Drawing.Size(190, 50);
this.listView1.TabIndex = 5;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 70;
//
// columnHeader2
//
this.columnHeader2.Text = "Grade";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 40;
//
// columnHeader3
//
this.columnHeader3.Text = "Battle";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 100;
and...my_SizeChanged(object sender, System.EventArgs e)
{
this.listView1.columns[2].Width=-2;
this.columnHeader3.Width=-2;
}
I am going to make it. complete the vision.
|
|
|
|
|
How can I edit existing attribute in xml file.
|
|
|
|
|
For example, you can use XmlDocument . You only need to find your atribute, change its value and save changes with XmlDocument.Save() method. Or you can use XmlReader/XmlWriter combination + temp file to do the same. Which to choose depends on size of XML file. (use XmlReader/XmlWriter for really big files)
Btw you can (should) post this to XML/XSL forum.
David
|
|
|
|
|
I have a windows service and i want it to send a message such as ("i'm processing") when i start doing a function to an application (web or windows app). How can i do that?
Anyone can help me? I'm very need it for my project. Thanks!
|
|
|
|
|
Did you look into .NET remoting? You can host a remote object in your service, get a reference to it in your application and then call the appropriate method on the remote object when you want to send a message.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|