Set RadMenuItem visible

12 posts, 1 answers
  1. yesaya handoyo
    yesaya handoyo avatar
    10 posts
    Member since:
    Jan 2010

    Posted 30 Dec 2010 Link to this post

    Hi all,i wonder is it possible to set RadMenuItem to visible based on database value..Thanks
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hello,

    Yes, just get your database value as a boolean and set the visible property according to the value.
    If you need further help, please let me know
    thanks
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. yesaya handoyo
    yesaya handoyo avatar
    10 posts
    Member since:
    Jan 2010

    Posted 30 Dec 2010 Link to this post

    May i ask for an example how to achieve it?I'm trying to compare the string which was queried with the RadMenuItem Text.If it's the same then the menu will be shown.Thanks..
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Which database are you using?
    Richard
  6. yesaya handoyo
    yesaya handoyo avatar
    10 posts
    Member since:
    Jan 2010

    Posted 30 Dec 2010 Link to this post

    I'm using microsoft access.
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hello,

    Please have a look at this link which shows how to use ExecuteScaler in MS Access. You just need to return the boolean value from your database, based on the result of the ExecuteScaler. You may also find this MSDN Link on editing an Access Database useful.

    hope that helps
    Richard
  8. yesaya handoyo
    yesaya handoyo avatar
    10 posts
    Member since:
    Jan 2010

    Posted 30 Dec 2010 Link to this post

    Could you give me an example how to set visibilty?Thanks..
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hello,

    For the menu
    Me.RadMenu1.Visible = False
    or for an individual item
    Me.RadMenuItem1.Visibility = ElementVisibility.Collapsed

    hope that helps
    Richard
  10. yesaya handoyo
    yesaya handoyo avatar
    10 posts
    Member since:
    Jan 2010

    Posted 30 Dec 2010 Link to this post

    Thanks.by the way can i use trycast to cast the RadMenuItem visiblity?
  11. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 31 Dec 2010 Link to this post

    Hello,

    For the RadMenuItem, you would need to do something like this..
    Private Function GetVisibility() As ElementVisibility
        ' db code 
        Dim returnValueFromDatabase As Boolean = False
        If returnValueFromDatabase Then
            Return ElementVisibility.Visible
        Else
            Return ElementVisibility.Collapsed
        End If
    End Function

    Me.RadMenuItem1.Visibility = GetVisibility()

    hope that helps
    Please remember to mark as answer
    Thanks
    Richard
  12. Rawad
    Rawad avatar
    23 posts
    Member since:
    Jan 2012

    Posted 10 Jul 2014 Link to this post

    Hello Dear

    Richard, your solution is working well, but how to resize the radcontextmenu,  lets say I have 4 items in the ContextMenu:
    1-Item1
    2-Item2
    3-Item3
    4-Item4

    And I want to hide some radmenuitem, so I put the following code :
    RadMenuItem2.Visibility = Telerik.WinControls.ElementVisibility.Hidden
    RadMenuItem3.Visibility = Telerik.WinControls.ElementVisibility.Hidden

    How to resize the radcontextmenu and to display   :
    1-Item1
    4-Item 4  

    In my case I have 2 lines empty  between item1 & item 4  .
    So how to make them Dock ?
      

  13. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 11 Jul 2014 Link to this post

    Hello,

    You can set the element's Visibility to Collapsed and the menu will be sized correctly.

    I hope this helps.

    Regards,
    Stefan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready