Lets just take this example I'm looking at now. I'm looking at the help
screen titled .NET Framework Class Library FolderBrowserDialog Class
[Visual Basic]. It gives an example at the bottom that begins with:
' The following example displays an application that provides the
ability to
' open rich text files (rtf) into the RichTextBox. The example demonstrates
' using the FolderBrowserDialog to set the default directory for opening
files.
' The OpenFileDialog class is used to open the file.
I don't know how to put this example in a program to try it. Where do I
paste the example to run it? Under form load? I don't think so. But
where? 6 2305
If you are running 2005, then that example is the complete class code. I
would create a new form named "FolderBrowserDialogExampleForm"
Then open it up in code view, select everything and hit delete. Then just
paste in the code from the example.
Viola, instant form!
If you have 2003, you have to be more careful not to delete or paste over
the " Windows Form Designer generated code " region.
Take all the code in the Sub New and cut and paste it after this line:
'Add any initialization after the InitializeComponent() call
Then delete the now empty Sub New from the example.
HTH,
Greg
"cj" <cj@nospam.nospam> wrote in message
news:OS**************@tk2msftngp13.phx.gbl... Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class [Visual Basic]. It gives an example at the bottom that begins with:
' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file.
I don't know how to put this example in a program to try it. Where do I paste the example to run it? Under form load? I don't think so. But where?
Ok, I'll look in a minute and see if I can figure it out. I'll let you
know. I am using 2003 and what you suggested for 2005 is what I had
done but your right it don't work in 2003.
How do you like 2005? Is it an official release yet or is it still
beta? Is it easier than 2003? Better? Just interested in your thoughts.
I'll get to work on that sample now.
Greg Burns wrote: If you are running 2005, then that example is the complete class code. I would create a new form named "FolderBrowserDialogExampleForm"
Then open it up in code view, select everything and hit delete. Then just paste in the code from the example.
Viola, instant form!
If you have 2003, you have to be more careful not to delete or paste over the " Windows Form Designer generated code " region.
Take all the code in the Sub New and cut and paste it after this line: 'Add any initialization after the InitializeComponent() call
Then delete the now empty Sub New from the example.
HTH, Greg
"cj" <cj@nospam.nospam> wrote in message news:OS**************@tk2msftngp13.phx.gbl...
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class [Visual Basic]. It gives an example at the bottom that begins with:
' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file.
I don't know how to put this example in a program to try it. Where do I paste the example to run it? Under form load? I don't think so. But where?
I downloaded my copy from MSDN a month ago. But I have in my hand the
retail upgrade edition my boss just got delivered today.
I love 2005, but there is SO much to learn. Everything from 2003 just
works as is, but there is so many new things I keep discovering and want to
start using.
Luckily, I haven't seen any of the ugly IDE issues some others are
complaining about.
Greg
"cj" <cj@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Ok, I'll look in a minute and see if I can figure it out. I'll let you know. I am using 2003 and what you suggested for 2005 is what I had done but your right it don't work in 2003.
How do you like 2005? Is it an official release yet or is it still beta? Is it easier than 2003? Better? Just interested in your thoughts.
I'll get to work on that sample now.
Greg Burns wrote: If you are running 2005, then that example is the complete class code. I would create a new form named "FolderBrowserDialogExampleForm"
Then open it up in code view, select everything and hit delete. Then just paste in the code from the example.
Viola, instant form!
If you have 2003, you have to be more careful not to delete or paste over the " Windows Form Designer generated code " region.
Take all the code in the Sub New and cut and paste it after this line: 'Add any initialization after the InitializeComponent() call
Then delete the now empty Sub New from the example.
HTH, Greg
"cj" <cj@nospam.nospam> wrote in message news:OS**************@tk2msftngp13.phx.gbl...
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class [Visual Basic]. It gives an example at the bottom that begins with:
' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file.
I don't know how to put this example in a program to try it. Where do I paste the example to run it? Under form load? I don't think so. But where?
Well, I guess I'll keep learning 2003 till I get 2005. At least what
I'm learning now will transfer over.
Back to the example code question. This example has everything inside a
Public Class FolderBrowserDialogExampleForm. I don't think I can just
take the sub new code out and put it inside that windows generated code
area wher you said. I tried but it gives me many errors.
I created a new solution and selected view code. I get this:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
End Class
Where do I paste the rest of the stuff in the example? Does Microsoft
have any documentation on how to use this sample code? I couldn't find
any.
Greg Burns wrote: I downloaded my copy from MSDN a month ago. But I have in my hand the retail upgrade edition my boss just got delivered today.
I love 2005, but there is SO much to learn. Everything from 2003 just works as is, but there is so many new things I keep discovering and want to start using.
Luckily, I haven't seen any of the ugly IDE issues some others are complaining about.
Greg
"cj" <cj@nospam.nospam> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Ok, I'll look in a minute and see if I can figure it out. I'll let you know. I am using 2003 and what you suggested for 2005 is what I had done but your right it don't work in 2003.
How do you like 2005? Is it an official release yet or is it still beta? Is it easier than 2003? Better? Just interested in your thoughts.
I'll get to work on that sample now.
Greg Burns wrote:
If you are running 2005, then that example is the complete class code. I would create a new form named "FolderBrowserDialogExampleForm"
Then open it up in code view, select everything and hit delete. Then just paste in the code from the example.
Viola, instant form!
If you have 2003, you have to be more careful not to delete or paste over the " Windows Form Designer generated code " region.
Take all the code in the Sub New and cut and paste it after this line: 'Add any initialization after the InitializeComponent() call
Then delete the now empty Sub New from the example.
HTH, Greg
"cj" <cj@nospam.nospam> wrote in message news:OS**************@tk2msftngp13.phx.gbl...
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class [Visual Basic]. It gives an example at the bottom that begins with:
' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file.
I don't know how to put this example in a program to try it. Where do I paste the example to run it? Under form load? I don't think so. But where?
Not to beat a dead horse, but in fact my advice for VB 2005 wasn't
technically correct either. Some of that code should be placed in the
form1.designer.vb partial class file to allow the IDE to be able to modify
it as well.
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Whoops! While the previous post would work, I should have pasted some of that stuff inside the InitializeComponent sub. That way the form can be further modified using the designer.
Greg
Thank you! I ran the program so it's working. I'll take a good look at
it to see how you did what you did. Hopefully it'll make sense to me.
It's about time I wrap things up here at the office to leave for
Christmas. I might be working on this over the holiday some though.
Have a Merry Christmas! And thanks again.
cj
Greg Burns wrote: Whoops! While the previous post would work, I should have pasted some of that stuff inside the InitializeComponent sub. That way the form can be further modified using the designer.
Greg
' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file. Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.IO
Public Class FolderBrowserDialogExampleForm Inherits Form
Private folderBrowserDialog1 As FolderBrowserDialog Private openFileDialog1 As OpenFileDialog
Private richTextBox1 As RichTextBox
Private mainMenu1 As MainMenu Private fileMenuItem As MenuItem Private WithEvents folderMenuItem As MenuItem, _ closeMenuItem As MenuItem, _ openMenuItem As MenuItem
Private openFileName As String, folderName As String
Private fileOpened As Boolean = False
#Region " Windows Form Designer generated code "
Public Sub New() MyBase.New()
'This call is required by the Windows Form Designer. InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() ' 'FolderBrowserDialogExampleForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Name = "FolderBrowserDialogExampleForm" Me.Text = "Form1"
Me.mainMenu1 = New System.Windows.Forms.MainMenu Me.fileMenuItem = New System.Windows.Forms.MenuItem Me.openMenuItem = New System.Windows.Forms.MenuItem Me.folderMenuItem = New System.Windows.Forms.MenuItem Me.closeMenuItem = New System.Windows.Forms.MenuItem
Me.openFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog Me.richTextBox1 = New System.Windows.Forms.RichTextBox
Me.mainMenu1.MenuItems.Add(Me.fileMenuItem) Me.fileMenuItem.MenuItems.AddRange( _ New System.Windows.Forms.MenuItem() {Me.openMenuItem, _ Me.closeMenuItem, _ Me.folderMenuItem}) Me.fileMenuItem.Text = "File"
Me.openMenuItem.Text = "Open..."
Me.folderMenuItem.Text = "Select Directory..."
Me.closeMenuItem.Text = "Close" Me.closeMenuItem.Enabled = False
Me.openFileDialog1.DefaultExt = "rtf" Me.openFileDialog1.Filter = "rtf files (*.rtf)|*.rtf"
' Set the Help text description for the FolderBrowserDialog. Me.folderBrowserDialog1.Description = _ "Select the directory that you want to use As the default."
' Do not allow the user to create New files via the FolderBrowserDialog. Me.folderBrowserDialog1.ShowNewFolderButton = False
' Default to the My Documents folder. Me.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal
Me.richTextBox1.AcceptsTab = True Me.richTextBox1.Location = New System.Drawing.Point(8, 8) Me.richTextBox1.Size = New System.Drawing.Size(280, 344) Me.richTextBox1.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or _ AnchorStyles.Bottom Or AnchorStyles.Right
Me.ClientSize = New System.Drawing.Size(296, 360) Me.Controls.Add(Me.richTextBox1) Me.Menu = Me.mainMenu1 Me.Text = "RTF Document Browser" End Sub
#End Region <STAThread()> _ Shared Sub Main() Application.Run(New FolderBrowserDialogExampleForm) End Sub
' Bring up a dialog to open a file. Private Sub openMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles openMenuItem.Click ' If a file is not opened, then set the initial directory to the ' FolderBrowserDialog.SelectedPath value. If (Not fileOpened) Then openFileDialog1.InitialDirectory = folderBrowserDialog1.SelectedPath openFileDialog1.FileName = Nothing End If
' Display the openFile dialog. Dim result As DialogResult = openFileDialog1.ShowDialog()
' OK button was pressed. If (result = DialogResult.OK) Then openFileName = openFileDialog1.FileName Try ' Output the requested file in richTextBox1. Dim s As Stream = openFileDialog1.OpenFile() richTextBox1.LoadFile(s, RichTextBoxStreamType.RichText) s.Close()
fileOpened = True
Catch exp As Exception MessageBox.Show("An error occurred while attempting to load the file. The error is:" _ + System.Environment.NewLine + exp.ToString() + System.Environment.NewLine) fileOpened = False End Try Invalidate()
closeMenuItem.Enabled = fileOpened
' Cancel button was pressed. ElseIf (result = DialogResult.Cancel) Then Return End If End Sub
' Close the current file. Private Sub closeMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles closeMenuItem.Click richTextBox1.Text = "" fileOpened = False
closeMenuItem.Enabled = False End Sub
' Bring up a dialog to chose a folder path in which to open or save a file. Private Sub folderMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles folderMenuItem.Click ' Show the FolderBrowserDialog. Dim result As DialogResult = folderBrowserDialog1.ShowDialog()
If (result = DialogResult.OK) Then folderName = folderBrowserDialog1.SelectedPath If (Not fileOpened) Then ' No file is opened, bring up openFileDialog in selected path. openFileDialog1.InitialDirectory = folderName openFileDialog1.FileName = Nothing openMenuItem.PerformClick() End If End If End Sub
End Class ' The following example displays an application that provides the ability to ' open rich text files (rtf) into the RichTextBox. The example demonstrates ' using the FolderBrowserDialog to set the default directory for opening files. ' The OpenFileDialog class is used to open the file. Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.IO
Public Class FolderBrowserDialogExampleForm Inherits Form
Private folderBrowserDialog1 As FolderBrowserDialog Private openFileDialog1 As OpenFileDialog
Private richTextBox1 As RichTextBox
Private mainMenu1 As MainMenu Private fileMenuItem As MenuItem Private WithEvents folderMenuItem As MenuItem, _ closeMenuItem As MenuItem, _ openMenuItem As MenuItem
Private openFileName As String, folderName As String
Private fileOpened As Boolean = False
#Region " Windows Form Designer generated code "
Public Sub New() MyBase.New()
'This call is required by the Windows Form Designer. InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() ' 'FolderBrowserDialogExampleForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Name = "FolderBrowserDialogExampleForm" Me.Text = "Form1"
Me.mainMenu1 = New System.Windows.Forms.MainMenu Me.fileMenuItem = New System.Windows.Forms.MenuItem Me.openMenuItem = New System.Windows.Forms.MenuItem Me.folderMenuItem = New System.Windows.Forms.MenuItem Me.closeMenuItem = New System.Windows.Forms.MenuItem
Me.openFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog Me.richTextBox1 = New System.Windows.Forms.RichTextBox
Me.mainMenu1.MenuItems.Add(Me.fileMenuItem) Me.fileMenuItem.MenuItems.AddRange( _ New System.Windows.Forms.MenuItem() {Me.openMenuItem, _ Me.closeMenuItem, _ Me.folderMenuItem}) Me.fileMenuItem.Text = "File"
Me.openMenuItem.Text = "Open..."
Me.folderMenuItem.Text = "Select Directory..."
Me.closeMenuItem.Text = "Close" Me.closeMenuItem.Enabled = False
Me.openFileDialog1.DefaultExt = "rtf" Me.openFileDialog1.Filter = "rtf files (*.rtf)|*.rtf"
' Set the Help text description for the FolderBrowserDialog. Me.folderBrowserDialog1.Description = _ "Select the directory that you want to use As the default."
' Do not allow the user to create New files via the FolderBrowserDialog. Me.folderBrowserDialog1.ShowNewFolderButton = False
' Default to the My Documents folder. Me.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal
Me.richTextBox1.AcceptsTab = True Me.richTextBox1.Location = New System.Drawing.Point(8, 8) Me.richTextBox1.Size = New System.Drawing.Size(280, 344) Me.richTextBox1.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or _ AnchorStyles.Bottom Or AnchorStyles.Right
Me.ClientSize = New System.Drawing.Size(296, 360) Me.Controls.Add(Me.richTextBox1) Me.Menu = Me.mainMenu1 Me.Text = "RTF Document Browser" End Sub
#End Region <STAThread()> _ Shared Sub Main() Application.Run(New FolderBrowserDialogExampleForm) End Sub
' Bring up a dialog to open a file. Private Sub openMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles openMenuItem.Click ' If a file is not opened, then set the initial directory to the ' FolderBrowserDialog.SelectedPath value. If (Not fileOpened) Then openFileDialog1.InitialDirectory = folderBrowserDialog1.SelectedPath openFileDialog1.FileName = Nothing End If
' Display the openFile dialog. Dim result As DialogResult = openFileDialog1.ShowDialog()
' OK button was pressed. If (result = DialogResult.OK) Then openFileName = openFileDialog1.FileName Try ' Output the requested file in richTextBox1. Dim s As Stream = openFileDialog1.OpenFile() richTextBox1.LoadFile(s, RichTextBoxStreamType.RichText) s.Close()
fileOpened = True
Catch exp As Exception MessageBox.Show("An error occurred while attempting to load the file. The error is:" _ + System.Environment.NewLine + exp.ToString() + System.Environment.NewLine) fileOpened = False End Try Invalidate()
closeMenuItem.Enabled = fileOpened
' Cancel button was pressed. ElseIf (result = DialogResult.Cancel) Then Return End If End Sub
' Close the current file. Private Sub closeMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles closeMenuItem.Click richTextBox1.Text = "" fileOpened = False
closeMenuItem.Enabled = False End Sub
' Bring up a dialog to chose a folder path in which to open or save a file. Private Sub folderMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles folderMenuItem.Click ' Show the FolderBrowserDialog. Dim result As DialogResult = folderBrowserDialog1.ShowDialog()
If (result = DialogResult.OK) Then folderName = folderBrowserDialog1.SelectedPath If (Not fileOpened) Then ' No file is opened, bring up openFileDialog in selected path. openFileDialog1.InitialDirectory = folderName openFileDialog1.FileName = Nothing openMenuItem.PerformClick() End If End If End Sub
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Myers |
last post by:
Hello folks:
(This message is also posted on the help forum at the pexpect
sourceforge page, but all indentation in the code got stripped away
when I submitted the post.)
For some time I've...
|
by: MLH |
last post by:
Access 97 has left examples out of much of HELP
that was included in Access 2.0. Anybody know
why? Or better still, where to find examples.
For example, Access 97 has no example code in
its...
|
by: ajikoe |
last post by:
Hello,
I used Visual C# Standard Edition.
I want to comment my program using xml commentary method,
I don't know why if I use value and example tag, it is not working / showed in the html...
|
by: KV |
last post by:
I'm new to OO Design, and I'm fixing to start writing my very first C#
program. Given the complexity of OO programming, I would like to run
something by this group and get general input.
My...
|
by: DM |
last post by:
This example copied from MSDN help does not work on any of my PC's. When
the dialog opens, itdisplays a blank page. I'm trying to create a dialog
that calls a function in the page that opened it...
|
by: Scott M. |
last post by:
Where will code that is preceded with:
/// <example>
/// some comments
/// </example>
actually show up?
I can see my <summaryand <remarkscode showing up in the code comment
pages and in...
|
by: NeoPa |
last post by:
CHAPTER 1 - TABLE OF CONTENTS (Including attached database)
CHAPTER 2 - INTRODUCTION
CHAPTER 3 - TABLE LAYOUT
CHAPTER 4 - FORM LAYOUT
CHAPTER 5 - FORM MODULE
CHAPTER 6 - CODE DISCUSSION (FILTER...
|
by: =?Utf-8?B?SmltIFdhbHNo?= |
last post by:
I have an VC++ MFC Win32 application that isn't working correctly when I
build it with VS2005. The problem seems to be in some ADO ActiveX controls
that came with VS6 and are now out of support....
|
by: Academia |
last post by:
The Help Class example requires only a simple copy, paste into a form and
run.
Which I did.
For it to relate to what I am trying to find out I set the "Help Navigator)
combobox to "Topic"
I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |