◘◘◘VisualXtremes◘◘◘

<a href="http://www.forums100.com/in.php?id=1665"><img src="http://www.forums100.com/button.php?id=1665" border="0" /></a><br><font face="Tahoma"><span style="font-size: 6pt; font-weight: 700"><a href="http://www.forums100.com" style="text-decoration: none">Top 100 Forums</a></span></font><!-- BEGIN TOP SITE LIST PLANET VOTING CODE -->
<center>
<a href="http://forumz.top-site-list.com/vote447.html">
<IMG SRC="http://forumz.top-site-list.com/images/voteimage/forumz-2.jpg" border=0></a><br><font size=1><a href="http://www.top-site-list.com/">Free TopSite</a></font>
</center>
<!-- END TOP SITE LIST PLANET VOTING CODE -->
VOTE NOW TO HELP US TO GROW!

Join the forum, it's quick and easy

◘◘◘VisualXtremes◘◘◘

<a href="http://www.forums100.com/in.php?id=1665"><img src="http://www.forums100.com/button.php?id=1665" border="0" /></a><br><font face="Tahoma"><span style="font-size: 6pt; font-weight: 700"><a href="http://www.forums100.com" style="text-decoration: none">Top 100 Forums</a></span></font><!-- BEGIN TOP SITE LIST PLANET VOTING CODE -->
<center>
<a href="http://forumz.top-site-list.com/vote447.html">
<IMG SRC="http://forumz.top-site-list.com/images/voteimage/forumz-2.jpg" border=0></a><br><font size=1><a href="http://www.top-site-list.com/">Free TopSite</a></font>
</center>
<!-- END TOP SITE LIST PLANET VOTING CODE -->
VOTE NOW TO HELP US TO GROW!

◘◘◘VisualXtremes◘◘◘

Would you like to react to this message? Create an account in a few clicks or log in to continue.

+10
williams8899
oliver6419
bardrick25
sshayndell12
kenneth659
david6720
yyanna2
DavidSmith
JOey
DaneX
14 posters

    [TUT] Save Button And Load Button For RichTextBox

    DaneX
    DaneX
    Admin
    Admin


    Posts : 28
    Tokens : 811
    Reputation : 0
    Join date : 2009-07-03
    Age : 32
    Location : Canada/Quebec

    [TUT] Save Button And Load Button For RichTextBox Empty [TUT] Save Button And Load Button For RichTextBox

    Post  DaneX Fri Jul 03, 2009 12:30 pm

    2 Buttons (btnLoad,btnSave)
    1 RichTextBox (rtbFileContents)
    1 OpenFileDialog component (ofdOpenFile)
    1 SaveFileDialog component (sfdSaveFile)

    First you need to be at the designer of the form. Open VS toolbox and
    find the Dialogs tab. Drag a OpenFileDialog component onto the form, do
    the same with a SaveFileDialog. These 2 items will show up in your
    component tray at the bottom of the form. Select the OpenFileDialog,
    look at the properties for it and change its name to 'ofdOpenFile'.
    Select the SaveFileDialog, look at the properties for it and change its
    name to sfdSaveFile.

    Code:
    Public Class Form1
    Dim FileName As String = ""

        Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

            sfdSaveFile.Filter = "Text Files(*.txt)|*.txt|Web Files(*.html,*.htm)|*.html;*.htm|PHP Files(*.php)|*.php"
            sfdSaveFile.FilterIndex = 1
            sfdSaveFile.InitialDirectory = "C:\"
            sfdSaveFile.AddExtension = True
            sfdSaveFile.Title = "Choose file to save."
            If String.IsNullOrEmpty(FileName) Then
                sfdSaveFile.FileName = "MyFile"
            Else
                sfdSaveFile.FileName = FileName
            End If

            If sfdSaveFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
                FileName = sfdSaveFile.FileName
                My.Computer.FileSystem.WriteAllText(FileName, rtbFileContents.Text, False)
            End If


        End Sub

        Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
            ofdOpenFile.Filter = "Text Files(*.txt)|*.txt|Web Files(*.html,*.htm)|*.html;*.htm|PHP Files(*.php)|*.php"
            '1 based array so first item is 1
            ofdOpenFile.FilterIndex = 1
            ofdOpenFile.Multiselect = False
            ofdOpenFile.InitialDirectory = "C:\"
            ofdOpenFile.FileName = ""
            ofdOpenFile.Title = "Choose file to load."

            If ofdOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
                'load the file that was selected into the Richtextbox
                FileName = ofdOpenFile.FileName

                rtbFileContents.Text = My.Computer.FileSystem.ReadAllText(FileName)
            End If

        End Sub

    End Class

    avatar
    JOey
    Moderator
    Moderator


    Posts : 16
    Tokens : 227
    Reputation : 1
    Join date : 2009-08-11

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  JOey Tue Aug 11, 2009 1:44 pm

    Thank you this is really helpful!
    avatar
    DavidSmith
    Leacher
    Leacher


    Posts : 4
    Tokens : 51
    Reputation : 0
    Join date : 2009-08-24

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  DavidSmith Mon Aug 24, 2009 2:56 am

    thank you!!

    first post !
    avatar
    yyanna2
    Leacher
    Leacher


    Posts : 7
    Tokens : 63
    Reputation : 0
    Join date : 2010-01-20

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  yyanna2 Fri Feb 05, 2010 4:19 am

    Admirable post.Thanks
    _____________
    Contract Hire
    avatar
    david6720
    Leacher
    Leacher


    Posts : 13
    Tokens : 184
    Reputation : 0
    Join date : 2010-03-05

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  david6720 Mon Apr 12, 2010 5:44 pm

    thanking a lot.
    good coding..Smile

    -------------------------

    Hotels Ballina
    avatar
    kenneth659
    Member
    Member


    Posts : 34
    Tokens : 429
    Reputation : 0
    Join date : 2010-04-22

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  kenneth659 Thu May 27, 2010 4:53 pm

    I try all the function and coding present over there and all are working correctly and executing also.
    __________________________
    Bodybuilding Supplements
    Supplements
    avatar
    sshayndell12
    Leacher
    Leacher


    Posts : 12
    Tokens : 198
    Reputation : 0
    Join date : 2010-05-14

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  sshayndell12 Thu Jun 03, 2010 2:18 pm

    The following code snippet shows how to load a text file in RichTextBox (RTB). Using the same approach, you may use any file.

    The XAML user interface is listed here:

    <Window x:Class="RichTextBoxSample.Window1"

    ____________________________________________
    Web Design Birmingham
    Website Design Birmingham
    avatar
    sshayndell12
    Leacher
    Leacher


    Posts : 12
    Tokens : 198
    Reputation : 0
    Join date : 2010-05-14

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  sshayndell12 Sat Jun 05, 2010 12:43 pm

    With VB you can create Save Button And Load Button For RichTextBox...

    Code:

    Imports System
    Imports System.IO
    Imports System.Windows
    Imports System.Windows.Controls
    Imports System.Windows.Documents
    Imports System.Windows.Media

    Namespace SDKSample

       Partial Public Class SaveLoadPrintRTB
          Inherits Page

          ' Handle "Save RichTextBox Content" button click.
          Private Sub SaveRTBContent(ByVal sender As Object, ByVal args As RoutedEventArgs)

             ' Send an arbitrary URL and file name string specifying
             ' the location to save the XAML in.
             SaveXamlPackage("C:\test.xaml")
          End Sub

          ' Handle "Load RichTextBox Content" button click.
          Private Sub LoadRTBContent(ByVal sender As Object, ByVal args As RoutedEventArgs)
             ' Send URL string specifying what file to retrieve XAML
             ' from to load into the RichTextBox.
             LoadXamlPackage("C:\test.xaml")
          End Sub

          ' Handle "Print RichTextBox Content" button click.
          Private Sub PrintRTBContent(ByVal sender As Object, ByVal args As RoutedEventArgs)
             PrintCommand()
          End Sub

          ' Save XAML in RichTextBox to a file specified by _fileName
          Private Sub SaveXamlPackage(ByVal _fileName As String)
             Dim range As TextRange
             Dim fStream As FileStream
             range = New TextRange(richTB.Document.ContentStart, richTB.Document.ContentEnd)
             fStream = New FileStream(_fileName, FileMode.Create)
             range.Save(fStream, DataFormats.XamlPackage)
             fStream.Close()
          End Sub

          ' Load XAML into RichTextBox from a file specified by _fileName
          Private Sub LoadXamlPackage(ByVal _fileName As String)
             Dim range As TextRange
             Dim fStream As FileStream
             If File.Exists(_fileName) Then
                range = New TextRange(richTB.Document.ContentStart, richTB.Document.ContentEnd)
                fStream = New FileStream(_fileName, FileMode.OpenOrCreate)
                range.Load(fStream, DataFormats.XamlPackage)
                fStream.Close()
             End If
          End Sub

          ' Print RichTextBox content
          Private Sub PrintCommand()
             Dim pd As New PrintDialog()
             If (pd.ShowDialog() = True) Then
                'use either one of the below     
                pd.PrintVisual(TryCast(richTB, Visual), "printing as visual")
                pd.PrintDocument(((CType(richTB.Document, IDocumentPaginatorSource)).DocumentPaginator), "printing as paginator")
             End If
          End Sub
       End Class
    End Namespace

    ---------------------------------------------
    Web Design Birmingham
    Website Design Birmingham
    avatar
    bardrick25
    Leacher
    Leacher


    Posts : 24
    Tokens : 318
    Reputation : 0
    Join date : 2010-05-12

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  bardrick25 Thu Jun 10, 2010 10:22 am

    I try all the function and coding present over there and all are working correctly and executing also.
    _______________________________________
    Hair Care Products
    Hair Products
    avatar
    oliver6419
    Leacher
    Leacher


    Posts : 24
    Tokens : 317
    Reputation : 0
    Join date : 2010-06-19

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  oliver6419 Thu Jul 08, 2010 1:01 pm

    The following code is correct and executing also.
    _________________________
    Designer Lingerie
    Wonderbra
    avatar
    williams8899
    Member
    Member


    Posts : 27
    Tokens : 324
    Reputation : 0
    Join date : 2010-07-10

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  williams8899 Fri Aug 06, 2010 9:46 pm

    The RichTextBox can be a very useful control to take in text input from a user. With minimal work, you can create a reasonable text editor based on this control. But there’s not much point in having a multifunctional RichTextBox around if you can’t save the input or redisplay it when needed.

    -------------------------------------------------
    UPVC Doors
    UPVC Front Doors
    avatar
    Stephany297
    Member
    Member


    Posts : 28
    Tokens : 364
    Reputation : 0
    Join date : 2010-09-08

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  Stephany297 Tue Nov 16, 2010 6:41 pm

    I will try all the function and coding present over there and all are working correctly and executing also.
    ________________________
    Link Building
    SEO Packages
    avatar
    aaric61
    Member
    Member


    Posts : 61
    Tokens : 803
    Reputation : 0
    Join date : 2010-12-10

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  aaric61 Fri Dec 24, 2010 1:15 pm

    The RichTextBox can be a very useful control to take in text input from a user. With minimal work, you can create a reasonable text editor based on this control.
    ________________________
    SEO Marketing
    SEO Company
    avatar
    oral1139
    Member
    Member


    Posts : 33
    Tokens : 384
    Reputation : 0
    Join date : 2010-12-29

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  oral1139 Mon Jan 10, 2011 8:56 am

    I try all the function and coding present over there and all are working correctly and executing also.
    ___________________________________
    SEO
    Search Engine Optimization
    avatar
    mmicky30
    Member
    Member


    Posts : 65
    Tokens : 695
    Reputation : 0
    Join date : 2011-01-29

    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  mmicky30 Mon Feb 07, 2011 11:02 am

    I try all the function and coding present over there and all are working correctly and executing also.
    ______________________________________
    Roller Blinds
    Blackout Roller Blinds

    Sponsored content


    [TUT] Save Button And Load Button For RichTextBox Empty Re: [TUT] Save Button And Load Button For RichTextBox

    Post  Sponsored content


      Current date/time is Tue May 21, 2024 12:39 am