473,505 Members | 13,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image stretch or reduced to fit inside button in VB.NET

115 New Member
i'm using VB.Net Application program.

i'm creating 64 button dynamically during run time. and from database i'm getting the description, font color, back color and picture path. and if the picture path is not nothing, then i need to display that picture in that button. if picture path is nothing, then need to display the description as button text using font color and back color.

this button values are not loaded only once. using button click Addhandler, each button values keeps on changing each time.

The Code i used to display is

Expand|Select|Wrap|Line Numbers
  1.        For Each c As Control In Controls
  2.             If c.Name = "ItemBtn-" & x Then
  3.                c.Text = ButtonText
  4.                c.ForeColor = System.Drawing.ColorTranslator.FromOle(btnFontColor)
  5.                c.BackColor = System.Drawing.ColorTranslator.FromOle(btnBackColor)
  6.                c.Tag = "ItemPageBtn-" & i
  7.                c.Location = New System.Drawing.Point(gLeft, gTop)
  8.            If btnPicture <> "" And btnPicture <> Nothing Then
  9.                    gButton.Image = Image.FromFile(btnPicture)
  10.                End If
  11.                c.Visible = True
  12.                c.Visible = True
  13.                Exit For
  14.            End If
  15.         Next
  16.  
while i run the program, the image is diplaying in correct button if picture path exist and button that didn't have the picture path is displaying the text.

but the image is not fitting inside the Button. i can see only half of the image. i need a way to make the Image stretched or reduced to fit inside button.

is it possible??? if anyone have any idea how to do this, please help me. and if you can provide an example, then it will be great help for me.

Thanks in advance.
Oct 22 '08 #1
4 13567
joedeene
583 Contributor
How about using the .BackgroundimageLayout Property and set it to ImageLayout.Stretch? Would that help?

joedeene
Oct 22 '08 #2
remya1000
115 New Member
Thank you for your help.

Code i used to to display picture is

Expand|Select|Wrap|Line Numbers
  1. dim img as new bitmap(filename)
  2. dim img2 as new bitmap(img, mybutton.width, mybutton.height) 
  3. mybutton.Image = img2
  4.  
How can I remove the image from the button? is there a way to set the button image to "None"???

if anyone have any idea how to do this, please help me. and if you can provide an example, then it will be great help for me.

Thanks in advance.
Oct 23 '08 #3
Plater
7,872 Recognized Expert Expert
mybutton.Image=null;
or for vb I suppose
mybutton.Image=nothing
Oct 23 '08 #4
remya1000
115 New Member
that worked. thank you so much.

Expand|Select|Wrap|Line Numbers
  1. Button1.Image = Nothing
  2.  
Oct 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6294
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF...
0
1526
by: Casey Hawthorne | last post by:
Is there a better way to delete the image from a Tkinter button other than the following: - reconstructing the button - image=blank.gif -- Regards,
2
62448
by: TAM | last post by:
Hi, I am using a table with height and width as 100%. I wish to use a background image of size W 62x H 314 pixels for one table cell. How do I make the background image stretch to fit the...
0
1786
by: gopal | last post by:
Hi, How to display the image icon in save button in SAveFileDialog control? Rgds JK
3
2390
Mauro
by: Mauro | last post by:
Hi! I created a usercontrol, inside it, there is a image control, I created a picture property, but when I try to change or load a picture in the image control in run time, I can't, it appears an...
4
1938
by: truptidalia | last post by:
Hi, I have added an image to my button. If I increase the size of the button, the image is visible in tile form. How do I stretch the image of the button. <input...
4
1395
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi everydoby! I have an issue, I have an static image, and I need to write text inside it in runtime, but I don't know how! I can't use absolute position in atributtes style. Thanks.
9
9857
by: ameshkin | last post by:
Hi guys, I'm a pretty good PHP programmer, but when it comes to JS, I just dont understand it! But I really need to learn. I'm having trouble doing the simplest thing! When someone clicks...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.