nd54 Posted May 2, 2003 Posted May 2, 2003 Hey all trying to get this Open File Dialog to work... When I hit cancel on the second time it adds the file to the list anyways Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click Dim ofd As New OpenFileDialog() Dim lv As ListViewItem ofd.Title = "Select FILE TO OPEN..." ofd.Filter = "All Files(*.*)|*.*" ofd.ShowDialog() If ofd.FileName = "" Then Exit Sub lv = ListView1.Items.Add(ofd.filename lv.subitem.add("test") lv.subitem.add("testing") end sub Thank You Quote
*Gurus* divil Posted May 2, 2003 *Gurus* Posted May 2, 2003 If ofd.ShowDialog() = DialogResult.Cancel Then Exit Sub You should be using that instead of checking the length of the filename. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
nd54 Posted May 2, 2003 Author Posted May 2, 2003 Thank You Divil... I guess im still use to vb6 Quote
*Gurus* divil Posted May 2, 2003 *Gurus* Posted May 2, 2003 Even in VB6 the best way was to use the CancelError property and trap the error :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.