|
John Simmons / outlaw programmer wrote: So much for easy interoperability...
Yes so much for the thing that is everything or the automated application generation tools that will eliminate the need for developers. They don't exist and maybe never will.
|
|
|
|
|
hi
I receive an exception at runtime when try to execute:
System.Diagnostics.Process[] Proc = System.Diagnostics.Process.GetProcesses();
exception type:
System.InvalidOperationException
exception message:
Process performance counter is disable, so the requested operation cannot be performed.
H.R
|
|
|
|
|
Take a look at this thread[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Can anyone tel me if u can join them
so for every node ther will be a checkBox
THNKS
kobkob
|
|
|
|
|
Try setting this property[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
THNKS
kobkob
|
|
|
|
|
In one of my projects, I have a form with a grid of controls on it. I create the controls on the fly, as there are a dynamic number of them. To keep track of the controls, I keep them in a ArrayList.
As I create each control, I bind a handler to it, to handle events.
So:
ArrayList aMembersComboBoxes = new ArrayList();<br />
ArrayList aRelationshipComboBoxes = new ArrayList();<br />
...<br />
aMembersComboBoxes.Insert(iPosition, new System.Windows.Forms.ComboBox());<br />
aRelationshipComboBoxes.Insert(iPosition, new System.Windows.Forms.ComboBox());<br />
...<br />
((ComboBox)aMembersComboBoxes[iPosition]).SelectedIndexChanged += new EventHandler(cmbMembers_SelectIndexChanged);<br />
((ComboBox)aRelationshipComboBoxes[iPosition]).SelectedIndexChanged += new EventHandler(cmbRelationship_SelectIndexChanged);<br />
In the handler for my first combobox (cmbMembers) I change the DataSource for my second combobox (cmbRelationship), based on the selection the user makes in the first combobox.
<br />
private void cmbRelationship_SelectIndexChanged(object sender, EventArgs e)<br />
{<br />
int i = aMembersComboBoxes.IndexOf((ComboBox)sender);<br />
<br />
if (((ComboBox)sender).SelectedItem.ToString().Contains("String"))<br />
{<br />
((ComboBox)aRelationshipComboBoxes[i]).DataSource = aRelationshipList_Strings;<br />
}<br />
}<br />
In this handler, the code works fine, because sender turns out to be the control I clicked on. But in the handler for the second combobox, the same code fails:
private void cmbRelationship_SelectIndexChanged(object sender, EventArgs e)<br />
{<br />
int i = aRelationshipComboBoxes.IndexOf((ComboBox)sender);<br />
}<br />
Because in this case, "sender" turns out to be the control that initiated the action (the code executing in cmbMember), not the control that received it.
How can I get the identity of the control that is RECEIVING the event, the one for whom the handler is firing?
Thanks in advance.
-- modified at 8:39 Wednesday 26th September, 2007
|
|
|
|
|
Not too sure what you mean but if
int i = aRelationshipComboBoxes.IndexOf((ComboBox)sender);
gives you the sender, wouldn't this (no pun intended)
int i = aRelationshipComboBoxes.IndexOf((ComboBox)this);
give you the receiver? Or am i totally missing the point?
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
no, "this" is the form. The code you described won't even compile... I need to know the index of the current control inside the ArrayList of controls aRelationshipComboBoxes[]...
|
|
|
|
|
I think there is probably something else wrong. If you use Reflector[^] you can see that the SelectedIndexChanged event is always fired by a ComboBox using "this" as the sender. Check out the OnSelectedIndexChanged(EventArgs) method.
I would recommend setting the Name property on the ComboBoxes that you are creating (assuming you are not already doing that).
Can you put together a small sample project and send it over?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Ignore my code for a second, it's probably confusing the issue.
Generically, how do you get the identity of the control for whom a handler is executing? I believe I'm looking for the C# equivalent of the VB "Me" keyword, here.
|
|
|
|
|
The "sender" parameter is the control that fired the event. I'm assuming that is what you are asking. The C# equilvalent of the VB.Net "Me" is "this".
So if you have two combo boxes and you hook them both up to the same event handler like:
private ComboBox comboBox1 = new ComboBox();
private ComboBox comboBox2 = new ComboBox();
private void CreateComboBoxes() {
this.comboBox1 = new ComboBox();
this.comboBox2 = new ComboBox();
this.comboBox1.Location = new System.Drawing.Point(51, 157);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
this.comboBox2.Location = new System.Drawing.Point(51, 184);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(121, 21);
this.comboBox2.TabIndex = 1;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
}
private void comboBox_SelectedIndexChanged(Object sender, EventArgs e) {
if (sender == this.comboBox1) {
}
else if (sender == this.comboBox2) {
}
}
Then you can use the sender to distinguish the control that fired the event. The sender will be the ComboBox whose selected indexed changed regardless of how it changed (e.g. through code or through user interaction).
In the comboBox_SelectedIndexChanged() method, "this" refers to the Form because the method is defined in the Form class.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
yeah, ignore my "Me" comment, too. I include too much.
Okay, write the second handler without typing "combobox1" or "combobox2". My controls are located in ListArrays. I can only refer to them by knowing what their index is.
So in comboBox_SelectedIndexChanged(Object sender, EventArgs e), I need to know which of my two comboboxes is executing. "sender" turns out to be the combobox you clicked on, UNLESS you actually clicked on ComboBox1 and the code therein caused the DataSource for ComboBox2 to change. At that point, ComboBox2 receives a "SelectedIndexChanged" message, whose "sender" is ComboBox1.
So - in comboBox_SelectedIndexChanged(Object sender, EventArgs e) - how can you figure out which control is having it's Selected Index changed, without referring to it by name?
|
|
|
|
|
I would need to see a sample of this happening. What I'm saying is that if the SelectedIndexChanged is being fired for the ComboBox2 (because of a DataSource change or any other reason) then the sender will always be ComboBox2. This is hard-coded into the .Net framework.
I think there is something else wrong in your code. The sender will always be the ComboBox that had it's selected index changed (regardless of whether the user clicked in the first ComboBox or not). So there must be a problem with how the events are hooked up or with something else being done before the event is fired.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Sorry! My bug. I was binding the same handler to two different combo types. I gotta stop working all night.
So then - I can always use "sender" to know which control instance received the event? Yay! I can go to bed now!
|
|
|
|
|
Oh, and thanks. I'm tired, so I'm not being as clear as I should be.
BTW, if you know any better way to find out who "the current control" is in my case than what I am doing ("I don't have a reference for myself, so here, find Sender in this ArrayList and return me the Index"), I'd take it. That feels very obtuse to me...
Good night!
|
|
|
|
|
If it's always one main ComboBox to one secondary ComboBox, then I would use a Dictionary[^]. This way you can use the first ComboBox as the Key, then quickly obtain the secondary ComboBox (which would be the value).
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I wish. It's an arbitrary number of "rows", each of which is composed of 10 controls.
I keep 10 ArrayLists(), one for each "column" in each row. Each ArrayList contains the control that goes in that "column" at that "row" (Index).
So at every point in my code where I need to refer to those controls, I use
. ((TypeOfControl)aNameOfArray[RowNum]).Property
Each column of controls shares an event handler. To find out which control is actually being fired upon, I have to use this:
. int i =aNameOfArray.IndexOf((TypeOfControl)sender);
Now that I have "i" (the index of this control in that specific ArrayList), I can use it to manage the other controls in that "row".
It doesn't seem so bad now, but while I was struggling with that bug I desparately wished for a shortcut like "thisControl" which I could refer to...
What would make life easier would be if ArrayList allowed multiple dimensions. However, it's really a Collection and apparently Collections don't allow that.
|
|
|
|
|
To acheive multiple dimensions you can have an ArrayList of ArrayLists. If you are using .Net 2.0 then I would recommend using a List[^].
For your problem above, I would probably create a main ArrayList that holds ArrayLists. So for each row of controls you would create an ArrayList and add your controls, then add that ArrayList to the main ArrayList in the proper position.
Then to determine what row a given control exists in, I would use a Dictionary. Declared as "Dictionary<control, int32="">", the dictionary would map a control to it's associated row in the main ArrayList.
This way you could easily add additional controls to the row without having to create a new ArrayList.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
FYI every Control has a Tag property (type: object), so you can store one reference there
to whatever you like. One ComboBox could point to another ComboBox, to an ArrayList, whatever.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I would always assume that sender is the control instance that "fired" the event. The form is the one receiving the event. I use the word "assume", because it's really up to the person who coded the control. For the .Net framework controls, I have never seen an instance were sender was not the associated control. If there is then it would probably be considered a bug.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
How to extract html code any web site using C#.Net
I mean : http://www.yahoo.com----in that site find the Urls,Emailid,phone
Pls give code
Reddy
|
|
|
|
|
Grabbing the HTML is easy, the rest probably involves regular expressions to parse the string that contains the page.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
allivelu wrote: How to extract html code any web site using C#.Net
I mean : http://www.yahoo.com----in that site find the Urls,Emailid,phone
I'm not sure exactly what you want. If you are looking to get the HTML for a webpage, load it in a WebBrowser object and use the DocumentText property to retrieve the HTML as a string.
If you are looking for the URLs, email, and phone numbers, you'll need to look at the string you got from calling browser.DocumentText for substrings that match the pattern of a URL, email address or phone number. The Regex class is what you might want to look at, since that is *really* helpful at doing pattern matching.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
i want to make something like windows simulation question ??????
if any one have any idea about creating this, Please reply quickly
many thanks
omer
|
|
|
|