Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 701331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:35:52+00:00 2026-05-14T03:35:52+00:00

So I have a project where there is some automatic initialization going on through

  • 0

So I have a project where there is some automatic initialization going on through some classes that are created automatically as global variables (yeah they are static instances). At a point inside this (it has no relation with the C# GUI for the user, so it isn’t derived from any C# class) I need to see if a flag is set or not.

I use toolstrip menu with checked and unchecked status in order to set or unset the flag. The problem is that I have difficulties to see if the flag is checked or not from this static class. My class is inside a different project/namespace and a DLL is created what later is linked to the GUI of the application. The GUI depends from this Manager class so making the Manager class to depend from the GUI is not an option. Nevertheless, I should be able to see its state knowing its name or through some other means. I have tried the following:

if(Application.OpenForms[0].Owner.Controls["_useLocalImageForInitToolStripMenuItem"].Enabled)
{  };

Now the problem is that on the upper code snippet I get a nasty error. So how do I do this?

The toolstrip menu:
alt text

The error:

See the end of this message for
details on invoking just-in-time
(JIT) debugging instead of this dialog
box.

************** Exception Text ************** System.ArgumentOutOfRangeException:
Index was out of range. Must be
non-negative and less than the size of
the collection. Parameter name: index
at
System.Collections.ArrayList.get_Item(Int32
index) at
System.Windows.Forms.FormCollection.get_Item(Int32
index) at
Manager.MyMainManager.MyMainManager.RealTimeInit()
in C:\Dropbox\My
Dropbox\Public\Program
Code\RoboCup\Manager\MyMainManager\MyMainManager.cs:line
494 at
mainApp.MainForm.ButtonInitClick(Object
sender, EventArgs e) in C:\Dropbox\My
Dropbox\Public\Program
Code\RoboCup\mainApp\MainForm.cs:line
389 at
System.Windows.Forms.Control.OnClick(EventArgs
e) at
System.Windows.Forms.Button.OnClick(EventArgs
e) at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs
mevent) at
System.Windows.Forms.Control.WmMouseUp(Message&
m, MouseButtons button, Int32 clicks)
at
System.Windows.Forms.Control.WndProc(Message&
m) at
System.Windows.Forms.ButtonBase.WndProc(Message&
m) at
System.Windows.Forms.Button.WndProc(Message&
m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m) at
System.Windows.Forms.NativeWindow.Callback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr
lparam)

alt text

With private System.Windows.Forms.ToolStripMenuItem _useLocalImageForInitToolStripMenuItem;

this._useLocalImageForInitToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
                    this._useLocalImageForInitToolStripMenuItem.Name = "_useLocalImageForInitToolStripMenuItem";
                    this._useLocalImageForInitToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
                    this._useLocalImageForInitToolStripMenuItem.Text = "Use local image for Initialization";
                    this._useLocalImageForInitToolStripMenuItem.Click += new System.EventHandler(this.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:35:53+00:00Added an answer on May 14, 2026 at 3:35 am

    Okay sort of I managed to do what I wanted however it does not looks good as any modification to the menu path will cause a non-functionality.

    var alfa = ((((Application.OpenForms[0].Controls["_menustripMenu"] 
                                                 as System.Windows.Forms.MenuStrip).
                     Items["_settingsToolStripMenuItem"] 
                                          as System.Windows.Forms.ToolStripMenuItem).
                     DropDownItems["_cameraToolStripMenuItem"] 
                                          as System.Windows.Forms.ToolStripMenuItem).
                     DropDownItems["_useLocalImageForInitToolStripMenuItem"] 
                                  as System.Windows.Forms.ToolStripMenuItem).Checked;
    

    Any cleaner solution ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one java project in netBeans. There are some packages, and classes in
I have a following situation in my project. There are some tag values which
I have a project that I am working on in django. There are a
I have an iOS (Obj-C) project that uses ARC (Automatic Reference Counting). According to
I have a Maven project that uses the jaxb2-maven-plugin to compile some xsd files.
So I have this Java project made up of several classes, some external JAR
I have a project that has some files that are fragile in a sense
Is there possible, to have some projects under a certain user.name and user.email and
The scope of this is that we have three main projects. Some of the
I have a project where there are Windows, FreeBSD and Linux servers. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.