שתף באמצעות


Make Labels Selectable

Question

Saturday, October 6, 2012 3:25 AM

I'm sure there's a way but how do I make label text able to be selected?

Bgeo99

All replies (4)

Saturday, October 6, 2012 4:02 AM ✅Answered | 1 vote

I'm sure there's a way but how do I make label text able to be selected?

Bgeo99

You can't (unless you make your own).

Use a textbox instead and set it to .ReadOnly = True, then set the background color appropriately.

Please call me Frank :)


Saturday, October 6, 2012 4:05 AM ✅Answered | 1 vote

Hi Bgeo99,

you have to see this thread related yours question : http://bytes.com/topic/net/answers/842158-vb-net-select-text-label

and suggest you to use textbox instead of label with following code -

Me.TextBox1.BorderStyle = BorderStyle.None
Me.TextBox1.ReadOnly = True
Me.TextBox1.SelectionStart() = 0
Me.TextBox1.SelectionLength = Me.TextBox1.Text.Length
Me.TextBox1.ScrollToCaret()
Me.TextBox1.Focus()

Pl. Mark/Proposed as Answer if found your solution Vote as Helpful if related to your topic. Always Motivate others by performing this Action.


Saturday, October 6, 2012 3:47 AM

What do you mean by how to make label text able to be selected?

You've taught me everything I know but not everything you know.


Saturday, October 6, 2012 4:45 AM

This code will allow you to copy all label text to the clipboard but not select specific text in the label.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    End Sub

    Private Sub Label1_MouseDown(sender As Object, e As EventArgs) Handles Label1.MouseDown
        Clipboard.SetDataObject(Label1.Text, False)
    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class

You've taught me everything I know but not everything you know.