Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem about menustrip in windows forms

Problem about menustrip in windows forms

Scheduled Pinned Locked Moved C#
helpdatabasewinforms
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arun kumar Gautam
    wrote on last edited by
    #1

    I have a menustrip like as a b c i wanna to add a new menuitem in this menu named as d from database and now my menustrip is looks like a b c d now m wanna to add another menuitem in this menu as e from database but now my menu shows a b c d a b c d e but i wanna tht my menu shows as a b c d e can anyone help me in it

    L 1 Reply Last reply
    0
    • A Arun kumar Gautam

      I have a menustrip like as a b c i wanna to add a new menuitem in this menu named as d from database and now my menustrip is looks like a b c d now m wanna to add another menuitem in this menu as e from database but now my menu shows a b c d a b c d e but i wanna tht my menu shows as a b c d e can anyone help me in it

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Show the code you are using; we cannot guess what is going wrong from the above.

      Use the best guess

      A 1 Reply Last reply
      0
      • L Lost User

        Show the code you are using; we cannot guess what is going wrong from the above.

        Use the best guess

        A Offline
        A Offline
        Arun kumar Gautam
        wrote on last edited by
        #3

        public void SubMenu(ToolStripMenuItem menuitem, string submenu) { string get_subcatagory = "select * from medicine_subcatagory where Cat_ID=(select Cat_ID from medicine_catagory where Med_Cat='" + allopathicToolStripMenuItem.Text + "')"; DataTable dt = d.getdata(get_subcatagory); foreach (DataRow dr in dt.Rows) { ToolStripMenuItem ssmenu = new ToolStripMenuItem(dr["Med_Sub"].ToString(),null, new EventHandler(ChildClick)); if (menuitem.DropDownItems.Contains(menuitem.DropDownItems[dr["Med_Sub"].ToString()])) { menuitem.DropDownItems.Remove(ssmenu); } else { menuitem.DropDownItems.Add(ssmenu); } } } thats he code i use for add submenu in menuitem

        L 1 Reply Last reply
        0
        • A Arun kumar Gautam

          public void SubMenu(ToolStripMenuItem menuitem, string submenu) { string get_subcatagory = "select * from medicine_subcatagory where Cat_ID=(select Cat_ID from medicine_catagory where Med_Cat='" + allopathicToolStripMenuItem.Text + "')"; DataTable dt = d.getdata(get_subcatagory); foreach (DataRow dr in dt.Rows) { ToolStripMenuItem ssmenu = new ToolStripMenuItem(dr["Med_Sub"].ToString(),null, new EventHandler(ChildClick)); if (menuitem.DropDownItems.Contains(menuitem.DropDownItems[dr["Med_Sub"].ToString()])) { menuitem.DropDownItems.Remove(ssmenu); } else { menuitem.DropDownItems.Add(ssmenu); } } } thats he code i use for add submenu in menuitem

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          And what happens when you step through it in your debugger? Although, at a guess it is failing the if expression. BTW please indent your code and put <pre> tags round it, so it looks like:

          public void SubMenu(ToolStripMenuItem menuitem, string submenu)
          {
          string get_subcatagory = "select * from medicine_subcatagory where Cat_ID=(select Cat_ID from medicine_catagory where Med_Cat='" + allopathicToolStripMenuItem.Text + "')";
          DataTable dt = d.getdata(get_subcatagory);

          foreach (DataRow dr in dt.Rows)
          {
              ToolStripMenuItem ssmenu = new ToolStripMenuItem(dr\["Med\_Sub"\].ToString(),null, new EventHandler(ChildClick));
              if (menuitem.DropDownItems.Contains(menuitem.DropDownItems\[dr\["Med\_Sub"\].ToString()\]))
              {
                  menuitem.DropDownItems.Remove(ssmenu);
              }
              else
              {
                  menuitem.DropDownItems.Add(ssmenu);
              }
          }
          

          }

          Use the best guess

          A 1 Reply Last reply
          0
          • L Lost User

            And what happens when you step through it in your debugger? Although, at a guess it is failing the if expression. BTW please indent your code and put <pre> tags round it, so it looks like:

            public void SubMenu(ToolStripMenuItem menuitem, string submenu)
            {
            string get_subcatagory = "select * from medicine_subcatagory where Cat_ID=(select Cat_ID from medicine_catagory where Med_Cat='" + allopathicToolStripMenuItem.Text + "')";
            DataTable dt = d.getdata(get_subcatagory);

            foreach (DataRow dr in dt.Rows)
            {
                ToolStripMenuItem ssmenu = new ToolStripMenuItem(dr\["Med\_Sub"\].ToString(),null, new EventHandler(ChildClick));
                if (menuitem.DropDownItems.Contains(menuitem.DropDownItems\[dr\["Med\_Sub"\].ToString()\]))
                {
                    menuitem.DropDownItems.Remove(ssmenu);
                }
                else
                {
                    menuitem.DropDownItems.Add(ssmenu);
                }
            }
            

            }

            Use the best guess

            A Offline
            A Offline
            Arun kumar Gautam
            wrote on last edited by
            #5

            yes it always goes into else code

            L 1 Reply Last reply
            0
            • A Arun kumar Gautam

              yes it always goes into else code

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Then you should be able to see how to fix it fairly easily.

              Use the best guess

              A 1 Reply Last reply
              0
              • L Lost User

                Then you should be able to see how to fix it fairly easily.

                Use the best guess

                A Offline
                A Offline
                Arun kumar Gautam
                wrote on last edited by
                #7

                i dont know how to do it... Can u help me in it... just giv me a simple concept about how cud i check tht a particular menuitem, which is already get from database, exist over there and thn how to add new menuitem from database into that previously created menu.....

                L 1 Reply Last reply
                0
                • A Arun kumar Gautam

                  i dont know how to do it... Can u help me in it... just giv me a simple concept about how cud i check tht a particular menuitem, which is already get from database, exist over there and thn how to add new menuitem from database into that previously created menu.....

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  A quick glance at the documentation[^] suggests that you are testing against the wrong object type.

                  Use the best guess

                  A 1 Reply Last reply
                  0
                  • L Lost User

                    A quick glance at the documentation[^] suggests that you are testing against the wrong object type.

                    Use the best guess

                    A Offline
                    A Offline
                    Arun kumar Gautam
                    wrote on last edited by
                    #9

                    thanks richard i solved my problem now

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups