CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2002
    Posts
    92

    How do I set focus to a text box?

    Just need to know how to make the call. Thanks.


  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: How do I set focus to a text box?

    TEXTBOX.FOCUS()

    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  3. #3
    Join Date
    Mar 2002
    Posts
    92

    Re: How do I set focus to a text box?

    In .NET this .focus() method doesn't seem to be a member function of the textbox class. Are you sure thats right?


  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Re: How do I set focus to a text box?

    Ok when I said textbox.focus() "textbox" should be whatever you named your textbox. e.g.

    Textbox1.Focus()
    MyTextBox.Focus()

    And yes I am positive that this is the case in VB.NET.

    Good Luck

    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  5. #5
    Join Date
    Aug 2020
    Posts
    5

    Re: How do I set focus to a text box?

    not work

  6. #6
    Join Date
    Aug 2020
    Posts
    5

    Re: How do I set focus to a text box?

    visual studio 2013 dx14.1 rich edit control not seen

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How do I set focus to a text box?

    Quote Originally Posted by amroasm View Post
    visual studio 2013 dx14.1 rich edit control not seen
    Not sure what your question may be. Are you saying that you are trying to set focus to a rich edit control and if so what code did you try if not then what are you asking?
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Aug 2020
    Posts
    5

    Re: How do I set focus to a text box?

    Visual Studio 2013 how to configure RichEdit Control...please help
    Toobox box not seen

  9. #9
    Join Date
    Aug 2020
    Posts
    5

    Re: How do I set focus to a text box?

    Set focus ok b4 i use to clear textbox "" now am using string.empty..now set focus working

  10. #10
    Join Date
    Aug 2020
    Posts
    5

    Re: How do I set focus to a text box?

    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim objWordApp As Word.Application
            objWordApp = New Word.Application
            Dim DoubleSpace As String = Chr(32) + Chr(32)
            Dim objDoc As Word.Document
            'Open an existing document.
            objWordApp.Documents.Open("D:\XYZ-23-08-20\Name7.docx")
            'Find and replace some text.
            objDoc.Content.Find.Execute(FindText:="Name:", ReplaceWith:="Name: " + TextBox1.Text)
            objDoc.Content.Find.Execute(FindText:="Address:", ReplaceWith:="Address: " + TextBox2.Text)
            objDoc.Content.Find.Execute(FindText:=" ", ReplaceWith:=DoubleSpace, Replace:=Word.WdReplace.wdReplaceAll)
            'Save and close the document.
            objWordApp.Documents.Item(1).Save()
            objWordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
            objWordApp.Quit()
            objWordApp = Nothing
       End Sub
    I Try to Pass Textbox .Text to ms word file ..error message
    Textbox1.text...null Value
    Last edited by 2kaud; August 26th, 2020 at 06:06 AM.

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How do I set focus to a text box?

    @amroasm, please start a new thread for any new questions rather than using this 18 year thread.
    Last edited by Arjay; August 26th, 2020 at 12:35 PM.

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

Featured