From: Onur Güzel on
On Mar 6, 3:37 am, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...(a)gmx.at> wrote:
> Am 05.03.2010 10:51, schrieb Mr. X.:
>
> > The code is for VB on VS 2008.
> > ...
> > dim b as Button
> > b = New Button()
> > b.Text = "test"
>
> > I didn't set any type, I suppose it is a default type.
> > As you said, it may be an interesting solution, I would like to know about.
>
> Sorry, Web Forms, Windows Forms, or something else?  The reason I am
> asking is that the Windows Forms 'Button' class does not have an 'Image'
> property.
>
> --
>   M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Hi,

System.Windows.Forms.Button class has Image property, because
ButtonBase base class has it.
http://msdn.microsoft.com/en-us/library/system.windows.forms.buttonbase.image.aspx

As the question OP asking, he/her needs to re-size button as the same
as image's size like that:

' Assign image to Button1
Button1.Image = Image.FromFile("c:\image.jpg")
' Resize button based on image's size
Button1.Size = New Size(Image.FromFile("c:\image.jpg").Size)

Onur Güzel
From: Herfried K. Wagner [MVP] on
Am 06.03.2010 15:21, schrieb Onur G�zel:
>>> The code is for VB on VS 2008.
>>> ...
>>> dim b as Button
>>> b = New Button()
>>> b.Text = "test"
>>
>>> I didn't set any type, I suppose it is a default type.
>>> As you said, it may be an interesting solution, I would like to know about.
>>
>> Sorry, Web Forms, Windows Forms, or something else? The reason I am
>> asking is that the Windows Forms 'Button' class does not have an 'Image'
>> property.
>
> System.Windows.Forms.Button class has Image property, because
> ButtonBase base class has it.
> http://msdn.microsoft.com/en-us/library/system.windows.forms.buttonbase.image.aspx

Hmmm, thanks for opening my eyes. I took a look at the 'Button' class'
documentation and the property was not listed there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
First  |  Prev  | 
Pages: 1 2
Prev: SendKeys and Keyboard Hook
Next: Serialization problem