Results 1 to 10 of 10

Thread: [ask] simple question about textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    146

    [ask] simple question about textbox

    dear guys

    i have a question

    i have a code like this

    Code:
    dim x as as string=""
    private sub form1_load......
    
    x &="bla bla bla......."
    textbox1.text = x
    
    end sub
    the question is
    in the text box when it's loaded there's a selection all the text..... HOw to remove the selection....and how to hide the cursor.....

    thx

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    146

    Re: [ask] simple question about textbox

    Quote Originally Posted by Deepak Sakpal
    textbox1.text = x
    TextBox1.SelectionStart = 0
    it works...thx
    Last edited by allopiloping; Jul 24th, 2008 at 05:19 AM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    146

    Re: [ask] simple question about textbox

    another question...
    how to make the cursor hide form the textbox, but not from the form....????

    and how to make the textbox just can read but there's nothing can edit it....??


    thx
    Last edited by allopiloping; Jul 24th, 2008 at 05:25 AM.

  5. #5

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    146

    Re: [ask] simple question about textbox

    Quote Originally Posted by Deepak Sakpal
    TextBox1.ReadOnly=True
    i know about it...

    but i want to make, we can't make a selection to the text.

    and then make the cursor hide in the text box...but not in the form.

    if i make cursor.hide...it hides all

    thx

  7. #7
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: [ask] simple question about textbox

    Well this is a dodgy example which will answer that question (until someone posts a nicer method of not allowing a textbox selection to be performed):
    Code:
    Private Sub TextBox1_MouseMove(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
        Cursor = Cursors.No
        Me.TextBox1.SelectionStart = 0
        Me.TextBox1.SelectionLength = 1
    End Sub
    
    Private Sub TextBox1_MouseLeave(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles TextBox1.MouseLeave
        Cursor = Cursors.Default
    End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  8. #8

  9. #9
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: [ask] simple question about textbox

    Why not simply use a label with a white background?

  10. #10
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: [ask] simple question about textbox

    Code:
        Private Sub TextBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.MouseEnter
            Windows.Forms.Cursor.Hide()
        End Sub
    
        Private Sub TextBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.MouseLeave
            Windows.Forms.Cursor.Show()
        End Sub
    Pure. Sweet. Simple. Just the way I like it.

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

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