Button show/hide icon

5 posts, 1 answers
  1. Jeffrey
    Jeffrey avatar
    6 posts
    Member since:
    Jun 2018

    Posted 16 Sep 2018 Link to this post

    Hi,

    I'm trying to being able to show or a hide an icon on a button when a PDF has been loaded. How do I show/hide an imported image resource for the project. Attached is a screenshot of the button when I set the image at design time but I need a way to show/hide this in code. Thanks!

    J

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 17 Sep 2018 Link to this post

    Hello, Jeffrey, 
     
    The RadButton.DisplayStyle property gives you the opportunity to control whether the image will be shown or not. If you need to show text and image, you set the DisplayStyle property to ImageAndText. Otherwise, set it to Text

    public RadForm1()
    {
        InitializeComponent();
     
        this.radButton1.Image = Properties.Resources.buttonDelete;
        this.radButton1.TextImageRelation = TextImageRelation.TextBeforeImage;
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        if (this.radButton1.DisplayStyle == Telerik.WinControls.DisplayStyle.ImageAndText)
        {
            this.radButton1.DisplayStyle = Telerik.WinControls.DisplayStyle.Text;
        }
        else
        {
            this.radButton1.DisplayStyle = Telerik.WinControls.DisplayStyle.ImageAndText;
        }
    }

    I hope this information helps. 

    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Jeffrey
    Jeffrey avatar
    6 posts
    Member since:
    Jun 2018

    Posted 28 Sep 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi, I had to modify the code to this:

    Me.btnUserCredentialsAttachPDF.Image = My.Resources.Pdf Me.btnUserCredentialsAttachPDF.TextImageRelation = TextImageRelation.TextBeforeImage

     

    My issue is that this shows the image only if I set it at design time. If I use:

    Me.btnUserCredentialsAttachPDF.DisplayStyle = Telerik.WinControls.DisplayStyle.ImageAndText

     

    In the code when I want to show the text and image after a user attached a PDF it does nothing and the button just has text.

  4. Answer
    Dimitar
    Admin
    Dimitar avatar
    2818 posts

    Posted 01 Oct 2018 Link to this post

    Hello Jeffrey, 
     
    I have tested this and it works on my side. For convenience, I prepared a small sample, based on the information that you provided so far and attached it to this thread. Could you please check it and let me know how it differs from your real setup? 

    I am looking forward to your reply.
     
    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Jeffrey
    Jeffrey avatar
    6 posts
    Member since:
    Jun 2018

    Posted 01 Oct 2018 in reply to Dimitar Link to this post

    Hi,

    Yes I was able to use your sample to make it work. Thanks!

Back to Top