ARTICLE

ButtonViewer: Using a Button to view Images

Posted by Mahesh Chand Articles | Visual Basic 2010 June 24, 2003
In .NET, the Image class is a wonderful class to view images. No matter what control you have, you just set the Image property of that control to an image and the control will display the image. Neat?
Download Files:
 
Reader Level:

Description:

You may be wondering what the hell is this ButtonViewer? Well, In .NET, the Image class is a wonderful class to view images. No matter what control you have, you just set the Image property of that control to an image and the control will display the image. Neat?

In this sample, the Browse button let you browse the the dir to pick an image (It won't display any thing else but an image, so don't try text or other files).



Code:

Setting Image property of a button displays an image.

Protected Sub button1_Click_1(ByVal sender As Object, ByVal e As System.EventArgs)
Dim fdlg As New OpenFileDialog
fdlg.Title = "C# Corner Open File Dialog"
fdlg.InitialDirectory = "c:\"
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"

fdlg.FilterIndex = 2
fdlg.RestoreDirectory =
True
If fdlg.ShowDialog() = DialogResult.OK Then
button2.Image = Image.FromFile(fdlg.FileName)
End If
Invalidate()
End Sub 'button1_Click_1

share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor