473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem when pressed "cancel" in OpenFileDialog

Hi,
Vb.net 2005 express i've been working, the problem is: I use
openfiledialog to browse files, i created some code to execute file
with OK button, no problem. But if i press "cancel" button as the
result of openfiledialog box, for example my filename's are added into
listbox or my audio file is being played from the beginning.

To explain better:

openfileplaylis t.ShowDialog()
ListBox1.Items. Add(openfilepla ylist.FileName)

1-That code adds file path into list box if click OK, but if i click
"cancel" it adds "OpenFileDialog 1" text into listbox. Why?

2-Also i want my files listed only as "filenames" , not full path like
c:\blabla\blaba \kklj\bla.mp3.

These 2 questions are very important for me.

Thanks for the answer from now.

Sep 25 '07
11 14278
Update regarding my previous message: If i do that coding (previous
message), when more then one items added to the listbox, it it brings
more problems such as not to recognize selected item by label2.text.

Private Sub ListBox1_click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles ListBox1.Click
Label2.Text = openfileplaylis t.FileName
End Sub

That code only allows me to get the last added file name to the
listbox, the previously added files' name cannot be recognized by
label2.text.

why?

Sep 26 '07 #11
On Sep 26, 6:21 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
Update regarding my previous message: If i do that coding (previous
message), when more then one items added to the listbox, it it brings
more problems such as not to recognize selected item by label2.text.

Private Sub ListBox1_click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles ListBox1.Click
Label2.Text = openfileplaylis t.FileName
End Sub

That code only allows me to get the last added file name to the
listbox, the previously added files' name cannot be recognized by
label2.text.

why?
Did you try the code I provided? It saves everything in one piece to
the listbox. There is no need to use a label, or a generic list,
everything is done from the ListBox's Items collection.

Please give it a try (all you need to do is copy and paste it into a
new form that contains a listbox named "ListBox1") and let me know how
it works!

Thanks,

Seth Rowe

Sep 27 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2975
by: Hernán Castelo | last post by:
hi i'm doing a reload() in JS in the production site i get the message "send again information...... : retry / cancel" but in development site works fine what differencia could be between the configuration of both IIS that allow these refresh or reload() ?
1
10501
by: Jane | last post by:
How to set the default button to "Cancel" instead of "OK" when pop-up the message box using the codes below: if (window.confirm("Are you sure you want to delete?")) { //Proceed to delete } Please advise, many thanks!!!! Jane.
5
8486
by: Quinn | last post by:
When users clicked a unkown mime type link such as Zip on my website, a "Save/Open/Cancel" dialog box pops up. Is there a way to detect which button users clicked by using ASP? actually I only what to record the "valid" click -- when Open/Save was clicked. Thanks ahead. Quinn
3
5222
by: dhnriverside | last post by:
Hi peeps I'm developing an intranet application which uses a main window and various popups created with javascript ( window.open() ). When the user saves what they are doing in the popup, i use opener.location.reload() to refresh the parent window. Most of the time this works fine, but one parent in particular always asks if we want to refresh the window (re post the form data), and I get that "retry / cancel" dialog box.
5
3347
by: Diego | last post by:
How do I capture a cancel event of Printer dialog box? Regards, Diego
4
1495
by: Graham Charles | last post by:
Hello, I'm finding that if I set the "Cancel" property during the AppStartup event, the application's Splash form remains loaded. A call to the Close property of the SplashForm at that point returns a cross-threading error, since (it appears) the Splashform is loaded by a different thread. Any advice? I could ignore the SplashForm application setting and just
1
4978
by: Appu | last post by:
How to Check in the window print dialog box whether we clicked either "print" or "cancel". while clicking a button i call wnidow.print() to pop up the windows PRint Dialog box. I want to check whether the user clicked either "print" or "cancel" in that print dialog box of windows. Please Help soon. Thanks T.Appasamy
1
2570
by: shaizaban | last post by:
hello, my question is as follows (very urgent): i generated in an aspx page a modalpopup ajax control. i inserted a user control into the panel contained in the popup control. the panel contains "ok" and "cancel", with no connectio to the user control. how can i cause the popup stay visible after "ok"? any button i press causes the popup to disappear!!! is there a way for it???
2
2178
Claus Mygind
by: Claus Mygind | last post by:
Is there a newer version of javaScript that will allow other text on the confirm dialogue box in place of "Ok" and "Cancel" Specifically for FireFox. I know that I can use visual basic for internet explorer, but that cannot be used in FireFox.
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.