|
Yes I would suggest ignoring any of the spearators, as you don't need to set teh check state of these...
|
|
|
|
|
ok, Is this a good way to approach this problem?
foreach (ToolStripMenuItem item in ((ToolStripSeparator)sender).Owner.Items)
{
}
|
|
|
|
|
No a better approach would be to:
foreach (ToolStripItem item in ((ToolStripDropDownItem)sender).Owner.Items)
{
if (item.GetType() == typeof(ToolStripMenuItem))
{
if (item == sender)
((ToolStripMenuItem)item).Checked = true;
else
((ToolStripMenuItem)item).Checked = false;
}
}
testing for the items type before you set teh check state of an item.
modified on Tuesday, August 24, 2010 8:41 AM
|
|
|
|
|
Thats way better but its bad because it overflows
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
|
|
|
|
|
really, the example I'm using here doesn't. I have a context menu with 3 menu items 1 separator 1 dropdown list and 1 test box ... and it seems to set the check state correctly...
Is your code a complete copy or my or have you just instered the elements you need?
I also assume that you are using this kind of approcah as you have multiple context menues and multiple menu options and only wish to have one function to do the work?
|
|
|
|
|
I put that code in and not edited it
|
|
|
|
|
ok, the only reason that you'd be getting a stack overflow from this loop is if new menu items were being added to the context menu strip, so in effect you'd be getting an ever increasing list.
That's something to check also to make sure that during each iterration of the loop that the count list count doesn't change.
As I said the example snippet I have here doesn't exhibit that issue....
Aslo as I mentioned earlier you can directly access the menu items and context menu required without looping round, for example:
myToolstripMenuItem1.Checked = true;
myToolstripMenuItem2.Checked = false;
myToolstripMenuItem3.Checked = false;
foreach (ToolStripMenuItem item in myContextMenuStrip.Items)
{
.......
}
modified on Tuesday, August 24, 2010 8:40 AM
|
|
|
|
|
I still don't know how to fix this over flow problem
|
|
|
|
|
As I mentioned something must be adding more ToolStripMneuItems to the ContextMenuStrip.Items collection.
Are you adding context menu items programmatically?
|
|
|
|
|
No I just made the strips as I did like, heres a example in visual mode
Strip1
Strip2
Strip2
Strip4
separator
Strip5
|
|
|
|
|
Ok I don't understand why you are getting a stack overflow, which is very strange...
What I would suggest then is this:
1. Turn all the items checked states off.
2. Tunr on the senders checked state...
strip1.Checked = false;
strip2.Checked = false;
strip3.Checked = false;
strip4.Checked = false;
strip5.Checked = false;
((ToolStripMenuItem)sender).Checked = true;
As you know have already defined the objects and have their names already you don't need to cycle for them, however its not as elegant as the other solution.
I'm still interested in why you getting the stack overflow, can you debug into the loop and examine ((ToolStripDropDownItem)sender).Owner.Items as this must be going up as it cycles round the loop...
And you are statically creating the items through the designer and not programtically??
|
|
|
|
|
Tip: ever heard of
is ?
...
if(item is ToolStripMenuItem)
...
|
|
|
|
|
Hello,
I am creating a mass mailing engine using C# which sends an email to many of its client. This engine includes many functionalities. One of them is tracking the email that is sent to the client (when it is opened on the emailing client like Outlook, Hotmail, Yahoo, Lotus Notes, etc., ) and also the attachments that are being downloaded by the client. All the tracking activities are to be logged into the database.
I searched many forums and got a solution of embedding 1px balnk image. I tried doing the same but i am not able to find the further steps, as to how will I actually include the entries in the db.
I am newbie to this functionality.
I would be very grateful, if anybody can help me with their small snippet of code (if any) or with the idea as to how should I go about.
Thanking you all in advance
Kind Regards
Pratik Shah.
Thanking you all in Advance
Regards
Pratik Shah
|
|
|
|
|
There isn't any way to track if an e-mail has been read if the user receiving it does not want you to know.
You could request a read receipt but the user would have to accept that it is sent to you.
Inserting an image that has to be downloaded will work but the user will still have to request that the image is downloaded, most e-mail clients will not automatically download them.
|
|
|
|
|
p4pratiks4shah wrote: I am creating a mass mailing engine
aka: A Spam Machine..?
|
|
|
|
|
Calla wrote: p4pratiks4shah wrote:
I am creating a mass mailing engine
aka: A Spam Machine..?
Not necessarily. I had to write email functionality into our backend DB app some years ago: our compliance department wanted the ability to sweep data from our field reps and send notifications only to those who needed them. Trying to manually configure a message for the right 50 or 60 people was no fun.
|
|
|
|
|
How do i check if a method exist in a named class library ?
thanks.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:00am.
|
|
|
|
|
Thnks for the link,
But what if i want to get a class name form an assembly?
thanks again.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:00am.
|
|
|
|
|
I've never heard of Google but I've heard of http://www.dogpile.com/
|
|
|
|
|
systemerror121 wrote: I've never heard of Google
I take it you've been living in a cave with no Internet access for the last 5 years?
|
|
|
|
|
You found Bin Laden.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
And using Google, you may find your question posted by someone else with a "let me google that for you" answer only...
|
|
|
|