teamdad Posted February 6, 2004 Posted February 6, 2004 I am having a problem with getting a menu item to check or uncheck. Any suggestions on what's going wrong with this? It obviously keeps the form on top of other windows when I can get it working. Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click If MenuItem3.Checked = False Then Me.TopMost = False Else MenuItem3.Checked = True Me.TopMost = True End If End Sub Thanks in advance for those that reply Quote
Administrators PlausiblyDamp Posted February 6, 2004 Administrators Posted February 6, 2004 You will also need to check / uncheck the item yourself. Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click MenuItem3.Checked = Not MenuItem3.Checked If MenuItem3.Checked = False Then Me.TopMost = False Else MenuItem3.Checked = True Me.TopMost = True End If End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders Iceplug Posted February 6, 2004 Leaders Posted February 6, 2004 Shouldn't you be making the checkmark inside of the If statement, and making it False in the Else statement? Also, you could just use MenuItem3.Checked = Not MenuItem3.Checked :). Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
*Experts* DiverDan Posted February 7, 2004 *Experts* Posted February 7, 2004 Actually, the method used by PlausiblyDamp is pretty cool!!! You could put that into a loop and go through all the menu items quickly. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Administrators PlausiblyDamp Posted February 7, 2004 Administrators Posted February 7, 2004 In fact you could reduce my code down to Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click MenuItem3.Checked = Not MenuItem3.Checked Me.TopMost = MenuItem3.Checked End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.