|
In my Windows.Forms app, I have a menu. That menu contains six menu items.
When the menu drops, I check a flag to see if the items in that menu should be disabled.
Here is the code:
private void miImport_DropDownOpening(object sender, EventArgs e)<br />
{<br />
foreach (ToolStripDropDownItem item in miImport.DropDownItems) item.Enabled = fMyFlag;<br />
}
This code executes flawlessly, disabling all the menu items when the flag is false.
However, once I add a separator bar between the items, this code throws the following exception:
Unable to cast object of type 'System.Windows.Forms.ToolStripSeparator' to type 'System.Windows.Forms.ToolStripDropDownItem'.
Can it possibly be true that the collection MenuItem.DropDownItems contains objects of different types? Isn't that verboten?
More importantly, why on earth would they do this? Why would any item they allow you to insert in the DropDownItem list not be treated as a DropDownItem?
This makes me pretty mad, as I'll have to write much longer code to individually disable these items.
Or am I missing something? Should I not be using "ToolStripDropDownItem" in my foreach loop?
Grr. I removed the item.Enabled = value line, and it still throws the exception. An empty foreach loop should NEVER throw an exception. If it's not an "each", why the hell is it being enumerated?
-- modified at 23:18 Thursday 11th January, 2007
|
|
|
|
|
I get the idea people just wait to see how often I'll Reply to myself.
Here's the code I came up with to replace that one line of code. If anybody knows a better method - say, using a different Type than "ToolStripDropDownItem " in my foreach loop - please feel free to let me know.
private void miImport_DropDownOpening(object sender, EventArgs e)<br />
{<br />
foreach (object item in miImport.DropDownItems)<br />
{<br />
Type typ = item.GetType();<br />
if (typ == typeof(ToolStripMenuItem))<br />
{<br />
ToolStripMenuItem mi = (ToolStripMenuItem)item;<br />
mi.Enabled = myFlag;<br />
}<br />
}<br />
}
|
|
|
|
|
Dear Joe
I can't able to clear your prob, but the below code will solve your prob.
for (int iLcnt = 0; iLcnt < toolStripDropDownButton1.DropDownItems.Count;iLcnt++ )
toolStripDropDownButton1.DropDownItems[iLcnt].Enabled = fMyFlag;
Cheers,
Chandru.
|
|
|
|
|
Thanks, Chandru. It turns out that ToolStripSeparators don't have an Enabled property, either, so either way I have to check the object type before setting the Enabled property.
How very inconvenient. And surprising, considering.
|
|
|
|
|
Hi all,
I have an application that cycles through Directories and finds Duplicate Image files (By Name).
It shows the original file name (FileInfo.Name) and the possible Duplicate (FileInfo.FullName) in the a CheckedListBox container on the form
What I want to do next is create a MouseHover Event that will show a form a bit like a tooltip with a preview of both Pictures in it.
I suppose I have a few questions.
1. Is a CheckedListBox the best solution for this to show the data? As the code runs through I store them in a List<listviewitem> which I then convert to an Array and AddRange onto the container.
2. What is the best way to get the preview to come up? I want it to dissapear as the user moves from one ListItem to another. The other issue is how can I get the MouseHover event to tell me which index I am on so I can retrieve the file paths to the imagine.
Suggestions greatly appreciated, and pointing to other online info that could me also greatly appreciated.
Regards
/TH
|
|
|
|
|
hello !!
plz do list topics for final year degree(ug) proj in c# for a beginner
MARTAND SHARDUL
B.TECH(C.S. & ENGG.)
|
|
|
|
|
How about something that trolls blog and forums for posts asking for help with school projects.
only two letters away from being an asset
|
|
|
|
|
I've got nothing against people asking for help, school project or not; people asking for complete solutions is the problem. I don't think the OP's question was out of line.
Steve
|
|
|
|
|
You dont think a student should be able to come up with their own end of year project? You think this a valuable and useful question for a forum?
|
|
|
|
|
Bear in mind, he's asking for "ideas" rather than solutions. What's to say there's no creative process in being given an idea, or even just a title, and running with that to make it your own. I was given a title for my project of "A webcam security camera". Rest assured that although I was given the title, I consider the entire creative process to be my own since the method I used and the approach I took was certainly not what would be expected from the title.
Also, the project itself is to create a solution. As a student it's incredibly hard to find a problem to solve if you have no starting point, but that isn't really the intended technical challenge of doing a computer science degree now is it? Mostly it's the people doing day to day work in the field that will have ideas for really interesting personal projects that would be possible with todays tech, but won't have the time to actually do them.
|
|
|
|
|
J4amieC wrote: You dont think a student should be able to come up with their own end of year project?
There is nothing wrong with asking for help. Sure maybe he can come up with an idea but perhaps someone else has a better one or can set him on the path to a better one.
J4amieC wrote: You think this a valuable and useful question for a forum?
Valuable to whom? To you I guess not, to the poster this may not be the case.
Steve
|
|
|
|
|
Don't you think people should do their own work, and then ask for help when they are stuck on a specific part of their code?
I work with a bunch of "developers" that were obviously given full projects on message boards.
|
|
|
|
|
Martand S wrote: final year degree
Martand S wrote: for a beginner
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
In my experience you can come out of uni and still be a beginner; the school of hard knocks is where you really learn the nuts and bolts.
Steve
|
|
|
|
|
true, but still...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Granted, that is the case, but you should (at least) be considered a good programmer inside of your environment (aka: big fish in a little pond). Then you have the rude awakening of the corporate world, where you realize everything you learned was just a rudimentary part of the ongoing learning process.
|
|
|
|
|
Wow, I missed that one. I guess I'm a beginner at CodeProject reading comprehension. :->
|
|
|
|
|
I don't know why people do so...!!!!!!!;P
they did not want to try one time to self develop. they wnat only Soln.
Pavan Pareta
|
|
|
|
|
The OP asked:
Martand S wrote: hello !!
plz do list topics for final year degree(ug) proj in c# for a beginner
You said:
Pavan_pareta wrote: don't know why people do so...!!!!!!!
they did not want to try one time to self develop. they wnat only Soln.
He wasn't asking for a solution, complete or otherwise. He was asking for suggestions for a "final year degree(ug) proj in c# for a beginner".
Steve
|
|
|
|
|
Do something that solves some problem from your other class (algebra, whatever), if you can apply results from your app in that class too.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
I learned C# in order to do my final year project - very rewarding. My project was a webcam security camera - to be implemented in whatever fashion or means I saw fit.
Other interesting ideas for projects I've heard along the way:
Nanite simulator (how would they communicate, create large scale structures with simple instructions)
Remote control helicopter controller (you might need an expensive toy for that one though)
Any of those are feasible projects and should give you plenty to study, write about and actually implement - there's a lot of real world and computer science theory to be studied and learned in the implementation of any of them
|
|
|
|
|
When you have a DataGridView of a table how do you sort multi-column in DataGridViw?
Any help will be appreciated.
Thank you.
Jamestown
|
|
|
|
|
|
Thanks. I'll try it to see how it works.
|
|
|
|
|
Is there one (and possibly if that include media player call, hide it's actually MP, but I hope to more elegant solution anyway)?
I know I seen some presentation where they did quick example of it, but can't remember how...
So?
|
|
|
|