Click here to Skip to main content
15,910,277 members
Home / Discussions / C#
   

C#

 
Questionhow to override the priority of an event Pin
kalaveer11-Jan-07 23:05
kalaveer11-Jan-07 23:05 
AnswerRe: how to override the priority of an event Pin
Seishin#12-Jan-07 0:11
Seishin#12-Jan-07 0:11 
AnswerRe: how to override the priority of an event Pin
S. Senthil Kumar12-Jan-07 6:48
S. Senthil Kumar12-Jan-07 6:48 
Questionchanging data type of a column of datatable with data Pin
amitcoder8311-Jan-07 22:38
amitcoder8311-Jan-07 22:38 
QuestionAdding own descriptions to intelli sense Pin
JacquesDP11-Jan-07 22:34
JacquesDP11-Jan-07 22:34 
AnswerRe: Adding own descriptions to intelli sense Pin
stancrm11-Jan-07 23:15
stancrm11-Jan-07 23:15 
GeneralRe: Adding own descriptions to intelli sense Pin
JacquesDP11-Jan-07 23:30
JacquesDP11-Jan-07 23:30 
GeneralRe: Adding own descriptions to intelli sense Pin
JacquesDP12-Jan-07 0:15
JacquesDP12-Jan-07 0:15 
QuestionCalling Managed code from c# dll. Is it possible? Pin
chandraskar11-Jan-07 22:33
chandraskar11-Jan-07 22:33 
AnswerRe: Calling Managed code from c# dll. Is it possible? Pin
Guffa11-Jan-07 22:55
Guffa11-Jan-07 22:55 
Questionregarding datagridview printing option in c# winforms Pin
vsekharbandaru11-Jan-07 22:03
vsekharbandaru11-Jan-07 22:03 
Questionhow to manage Device(s) from USB port ? Pin
hdv21211-Jan-07 21:56
hdv21211-Jan-07 21:56 
QuestionHowTo Get version of ActiveX on client & Update Pin
gholbrook11-Jan-07 21:22
gholbrook11-Jan-07 21:22 
QuestionHow to select a cell of a column of a list View?? Pin
Saira Tanwir11-Jan-07 19:14
Saira Tanwir11-Jan-07 19:14 
AnswerRe: How to select a cell of a column of a list View?? Pin
Nader Elshehabi11-Jan-07 21:32
Nader Elshehabi11-Jan-07 21:32 
AnswerRe: How to select a cell of a column of a list View?? Pin
CPallini11-Jan-07 22:37
mveCPallini11-Jan-07 22:37 
Questionhow to read information from pdf files Pin
deepualuru11-Jan-07 18:32
deepualuru11-Jan-07 18:32 
QuestionMonitor letter Drive (D:) Pin
picasso211-Jan-07 18:15
picasso211-Jan-07 18:15 
AnswerRe: Monitor letter Drive (D:) Pin
stancrm11-Jan-07 19:53
stancrm11-Jan-07 19:53 
AnswerRe: Monitor letter Drive (D:) Pin
Nader Elshehabi11-Jan-07 21:37
Nader Elshehabi11-Jan-07 21:37 
QuestionAccessing Image from MS Access. [modified] Pin
Shaurya_Rastogi11-Jan-07 18:09
Shaurya_Rastogi11-Jan-07 18:09 
QuestionDataGrid Pin
swjam11-Jan-07 17:57
swjam11-Jan-07 17:57 
AnswerRe: DataGrid Pin
Nader Elshehabi11-Jan-07 21:48
Nader Elshehabi11-Jan-07 21:48 
Questionerror in storage.InsertRecords [modified] Pin
tahreen shah11-Jan-07 17:11
tahreen shah11-Jan-07 17:11 
QuestionWhen is a DropDownItem not a DropDownItem? [modified] Pin
JoeRip11-Jan-07 16:55
JoeRip11-Jan-07 16:55 
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

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.