Results 1 to 5 of 5

Thread: Form and code help.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83

    Form and code help.

    I have two problems first Im trying to load a new form that tells the user that the file is not yet saved and asks them if they'd like to save the file.

    How do I return to the last event if they say no?

    Code:
      
        Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click
    
            'Yes Save the file
            Save()
            Me.Close()
    
    
        End Sub
    
        Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
            'No Dont save the file
    
        End Sub
    Second when I use this in the main form the txtTextBox.SaveFile is underlined with an error about it not being part of the windows.forms.textbox namespace.


    Code:
    Public Sub Save()
    
            If strFilename = "" Then
                SaveFileDialog1.ShowDialog()
                strFilename = SaveFileDialog1.FileName
            End If
    
            
            'txtTextBox.SaveFile is underlined below:       
            txtTextBox.SaveFile(strFilename & ".txt")
    Any Ideas?
    Last edited by Jes|er; Aug 7th, 2002 at 08:57 PM.
    12/32/84 - I need some code to make me a sandwhich.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    1) use .ShowDialog isntead of Show which makes the form modal so that when it opens, the calling code pauses there until the form is closes


    2) Because there is no such method as SaveFile. Dont know where you got that from
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    savefile is part of the RichTextBox, not TextBox
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Thanks for info. Any chance you know another way with #2 ?
    A way that I cant list a default extension with textbox.
    12/32/84 - I need some code to make me a sandwhich.

  5. #5
    Junior Member
    Join Date
    Aug 2002
    Location
    Georgia
    Posts
    27
    So does that mean that if I want to save information on a form I must use RichTextBox's rather that TextBoxes? And does this code work for combobox's as well?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width