Click here to Skip to main content
15,923,197 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow do I switch between forms by hiding the other Pin
DevQuest14-Apr-05 9:37
DevQuest14-Apr-05 9:37 
AnswerRe: How do I switch between forms by hiding the other Pin
Anonymous14-Apr-05 10:07
Anonymous14-Apr-05 10:07 
GeneralRe: How do I switch between forms by hiding the other Pin
DevQuest14-Apr-05 11:22
DevQuest14-Apr-05 11:22 
GeneralRe: How do I switch between forms by hiding the other Pin
Mitch F.14-Apr-05 14:24
Mitch F.14-Apr-05 14:24 
AnswerRe: How do I switch between forms by hiding the other Pin
rhenerlau19-Apr-05 17:19
rhenerlau19-Apr-05 17:19 
GeneralCrystal Report TextObject Pin
dpagka14-Apr-05 5:15
dpagka14-Apr-05 5:15 
Generalimage button Pin
Lisana14-Apr-05 3:18
Lisana14-Apr-05 3:18 
GeneralRe: image button Pin
Dave Kreskowiak14-Apr-05 4:15
mveDave Kreskowiak14-Apr-05 4:15 
There are (2) things you should know about using File Paths:

1) Don't EVER hard code path's like you did in this statement.

2) Don't EVER assume the file is in the "Current Directory" or "Working Directory". Always use fully qualified paths to files.

Right now, you're probably trying to figure out how to use a fully qualified path without knowing what that path is???

Easy. What you should be doing is building a path using a "known" location as a reference. The Application.StartupPath property will tell you from which folder your .EXE was loaded, or launched, from. If your .GIF file is in the same folder as your .EXE, you have a "known" starting point. All you have to do now is build the complete path to the file.

But wait a minute! Most beginners will use string concatenation to do this. Something like:
Dim myGifFile As String = Application.StartupPath & "\myGifFile.GIF"

Don't EVER do this! Instead, use a class that's specifically designed to do this, and more, using the proper path seperation characters and build rules for the platform that it's running on. The Path class does just this. Specifically, what you're looking for is:
Dim myGifFile As String = Path.Combine( Application.StartupPath, "myGifFile.GIF" )

Path.Combine takes (2) arguments. The first being the beginning of the path and the second being the ending. You don't have to worry about prepended or appended path seperation characters either. Path.Combine will take care to make sure that the path it generates is in a legal format.

Assuming that your .GIF image is in the same folder as the .EXE, your code should look more like this:
'  Build a new button control
Dim aImageButton As New Button
With aImageButton
    Dim imagePath As String = Path.Combine( Application.StartupPath, "checkbox_checked.gif" )
    .Image = Image.FromFile( imagePath )
    .Name = entity
    .Text = ""
    .ImageAlign = ContentAlignment.MiddleCenter
    .FlatStyle = FlatStyle.Flat
    .Location = New Point(10, y)
    .Width = 20
    .Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonclickHandler
' Finally, add the control to the form
tpgContact.Controls.Add(aImageButton)



RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: image button Pin
Lisana14-Apr-05 5:44
Lisana14-Apr-05 5:44 
GeneralRe: image button Pin
Dave Kreskowiak14-Apr-05 5:56
mveDave Kreskowiak14-Apr-05 5:56 
GeneralRe: image button Pin
Lisana14-Apr-05 6:07
Lisana14-Apr-05 6:07 
GeneralRe: image button Pin
Dave Kreskowiak14-Apr-05 6:13
mveDave Kreskowiak14-Apr-05 6:13 
GeneralRe: image button Pin
Lisana14-Apr-05 6:17
Lisana14-Apr-05 6:17 
GeneralRe: image button Pin
Dave Kreskowiak14-Apr-05 8:17
mveDave Kreskowiak14-Apr-05 8:17 
GeneralRe: image button Pin
Lisana14-Apr-05 9:16
Lisana14-Apr-05 9:16 
GeneralRe: image button Pin
rwestgraham14-Apr-05 10:07
rwestgraham14-Apr-05 10:07 
GeneralRe: image button Pin
Lisana14-Apr-05 10:41
Lisana14-Apr-05 10:41 
GeneralRe: image button Pin
Dave Kreskowiak15-Apr-05 3:33
mveDave Kreskowiak15-Apr-05 3:33 
GeneralRe: image button Pin
Lisana15-Apr-05 3:42
Lisana15-Apr-05 3:42 
GeneralRe: image button Pin
Lisana14-Apr-05 6:19
Lisana14-Apr-05 6:19 
GeneralRe: image button Pin
rwestgraham14-Apr-05 9:47
rwestgraham14-Apr-05 9:47 
GeneralUsing Wavelet in VB Pin
Anonymous14-Apr-05 2:25
Anonymous14-Apr-05 2:25 
GeneralRe: Using Wavelet in VB Pin
Dave Kreskowiak14-Apr-05 3:49
mveDave Kreskowiak14-Apr-05 3:49 
GeneralHighlighting Datagrid specific items Pin
bibipopopopo14-Apr-05 1:26
bibipopopopo14-Apr-05 1:26 
GeneralRe: Highlighting Datagrid specific items Pin
Dave Kreskowiak14-Apr-05 3:45
mveDave Kreskowiak14-Apr-05 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.