locked
EnableDisable Nav Buttons RRS feed

  • Question

  • Good Day,
          I have 2 forms with bindingNavigator and have a simple routine
    to enable/disable navigator buttons.  Each  nav button is assigned to a tag value. The problem is that if I want to enable/disable multiple nav buttons  I have to call the routine twice.

        EnableDisableNavBtn(NavMain, NavMain.Item(1), false)
          EnableDisableNavBtn(NavMain, NavMain.Item(2), false)
          ...
          Public Sub EnableDisableNavBtn(Byval obj as Object, Byval
    MenuItem as ToolStripitem, bflag as boolean...)

              if typeof Obj is bindingNavigator then...
              if MenuItem.tag = 0 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 1 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 2 then
                 MenuItem .Enabled = bFlag ...
          End sub

         I would like to do it in one shot meaning:
          EnableDisableNavBtn(NavMain, NavMain.Item(1,2), false)

         Could someone please give me an example.  Thanks for the advice.

    Ian
    Monday, May 21, 2007 6:04 AM

Answers

  • Public Sub EnableDisableNavBtn(Byval obj as Object, Byval
    MenuItem as ToolStripitem, bflag as boolean...)

              if typeof Obj is bindingNavigator then...

    for i as integer = 0 to menuitem.dropdownitems.count - 1

              if MenuItem.tag = 0 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 1 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 2 then
                 MenuItem .Enabled = bFlag ...

    next

          End sub


          EnableDisableNavBtn(NavMain, NavMain.Item, false)

    Monday, May 21, 2007 9:23 AM

All replies

  • Public Sub EnableDisableNavBtn(Byval obj as Object, Byval
    MenuItem as ToolStripitem, bflag as boolean...)

              if typeof Obj is bindingNavigator then...

    for i as integer = 0 to menuitem.dropdownitems.count - 1

              if MenuItem.tag = 0 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 1 then
                 MenuItem .Enabled = bFlag
              Elseif MenuItem.tag = 2 then
                 MenuItem .Enabled = bFlag ...

    next

          End sub


          EnableDisableNavBtn(NavMain, NavMain.Item, false)

    Monday, May 21, 2007 9:23 AM
  • Thanks weirdbearmt for the feedback.  I still have a question, let say, I want to disable only nav buttons 3 & 4 and leave others enaled - how would I do that? One way I thought is to pass in tag values for nav buttons 3&4 to routine.

    Any idea?

     

    Regards,

    Ian

    Monday, May 21, 2007 7:34 PM
  • Hi Ian

     

    Probably best to pass in a collection of buttons that yuo want to disable etc.

     

     

    Friday, May 25, 2007 11:57 AM