This is a migrated thread and some comments may be shown as answers.

Button show/hide icon

4 Answers 464 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Jeffrey
Top achievements
Rank 1
Jeffrey asked on 16 Sep 2018, 06:56 PM

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

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Sep 2018, 02:01 PM
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.
0
Jeffrey
Top achievements
Rank 1
answered on 28 Sep 2018, 11:18 PM

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.

0
Accepted
Dimitar
Telerik team
answered on 01 Oct 2018, 08:43 AM
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.
0
Jeffrey
Top achievements
Rank 1
answered on 01 Oct 2018, 08:21 PM

Hi,

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

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Jeffrey
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jeffrey
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or