Click here to Skip to main content
16,006,013 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Database Issues: Can't save a thing! Pin
Christian Graus26-Sep-06 12:30
protectorChristian Graus26-Sep-06 12:30 
GeneralRe: Database Issues: Can't save a thing! Pin
The ANZAC26-Sep-06 23:18
The ANZAC26-Sep-06 23:18 
GeneralRe: Database Issues: Can't save a thing! Pin
Dave Kreskowiak27-Sep-06 2:22
mveDave Kreskowiak27-Sep-06 2:22 
GeneralRe: Database Issues: Can't save a thing! Pin
The ANZAC27-Sep-06 21:35
The ANZAC27-Sep-06 21:35 
GeneralRe: Database Issues: Can't save a thing! Pin
Dave Kreskowiak28-Sep-06 3:45
mveDave Kreskowiak28-Sep-06 3:45 
QuestionRegardin displaying parent node Pin
praveen kumar mahto26-Sep-06 11:30
praveen kumar mahto26-Sep-06 11:30 
AnswerRe: Regardin displaying parent node Pin
Dave Kreskowiak27-Sep-06 9:10
mveDave Kreskowiak27-Sep-06 9:10 
QuestionLooping through controls using FOR EACH Pin
MatthysDT26-Sep-06 5:34
MatthysDT26-Sep-06 5:34 
Hi, I need some help with the FOR EACH command, here is my code:

Dim b As New ToolStripMenuItem
        For Each b In Me.cmsTestList.Items
            Debug.Print(b.Name)
            Debug.Print(b.Tag)

            If b.CheckOnClick = True Then
                If b.Tag = "check" Then
                    b.Checked = True
                Else
                    b.Checked = False
                End If
            End If

        Next


cmsTestList is of the type Windows.Forms.ContextMenuStrip
and
cmsTestList.Items returns a Windows.Forms.ToolStripItemCollection



I was under the impression that the object "b" will always be of the type: ToolStripMenuItem since I specified explicitly FOR EACH ToolStripMenuItem.

But the code tries looping through other items in my menu such as 'System.Windows.Forms.ToolStripTextBox'. This is not a ToolStripMenuItem as far as I know!

So resultingly the code breaks with the error:
Unable to cast object of type 'System.Windows.Forms.ToolStripTextBox' to type 'System.Windows.Forms.ToolStripMenuItem'.

I would never have thought that type casting will be necessary for this kind of implementation of the FOR EACH x IN commandMad | :mad: , and I don't know how to deal with this type casting either.Confused | :confused:

What I need to do is to loop through only the ToolStripMenuItems and not through all the other ToolStripItems as well!

Any ideas?

Kind Regards

you can't forget something you never knew...

"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann

AnswerRe: Looping through controls using FOR EACH Pin
mr_lasseter26-Sep-06 6:53
mr_lasseter26-Sep-06 6:53 
QuestionPlaying MP3 file Pin
mido1326-Sep-06 4:37
mido1326-Sep-06 4:37 
AnswerRe: Playing MP3 file Pin
Christian Graus26-Sep-06 12:32
protectorChristian Graus26-Sep-06 12:32 
Questionvertical tab control Pin
tatapower26-Sep-06 4:02
tatapower26-Sep-06 4:02 
QuestionNEVER_Minimizable form Pin
K edar V26-Sep-06 3:34
K edar V26-Sep-06 3:34 
AnswerRe: NEVER_Minimizable form Pin
Dave Sexton26-Sep-06 5:02
Dave Sexton26-Sep-06 5:02 
GeneralRe: NEVER_Minimizable form Pin
K edar V26-Sep-06 19:58
K edar V26-Sep-06 19:58 
Questiondatagrid columnheader alignment Pin
Smithers-Jones26-Sep-06 3:16
Smithers-Jones26-Sep-06 3:16 
AnswerRe: datagrid columnheader alignment Pin
Dave Sexton26-Sep-06 5:04
Dave Sexton26-Sep-06 5:04 
GeneralRe: datagrid columnheader alignment Pin
Smithers-Jones27-Sep-06 3:28
Smithers-Jones27-Sep-06 3:28 
QuestionCannot show multiple values for combobox DisplayMember? Pin
Rashar26-Sep-06 3:15
Rashar26-Sep-06 3:15 
AnswerRe: Cannot show multiple values for combobox DisplayMember? Pin
Coding1234566-Apr-09 18:18
Coding1234566-Apr-09 18:18 
QuestionReload main form? Pin
cstrader23226-Sep-06 2:07
cstrader23226-Sep-06 2:07 
AnswerRe: Reload main form? Pin
Christian Graus26-Sep-06 12:33
protectorChristian Graus26-Sep-06 12:33 
QuestionSend emails from windows form Pin
Nikhil Bandekar26-Sep-06 2:03
Nikhil Bandekar26-Sep-06 2:03 
AnswerRe: Send emails from windows form Pin
Christian Graus26-Sep-06 12:34
protectorChristian Graus26-Sep-06 12:34 
QuestionStoring Mails recieved in ms outlook into sql database Pin
gauravjee26-Sep-06 0:39
gauravjee26-Sep-06 0:39 

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.