Using a text box or label as buttons in visual studio studio c #

Is it possible to use a shortcut or text box in the same way as using a button in a C # studio visual document?

i.e. can it be selected and have a result similar to a button click?

+3
source share
4 answers

It’s best to use a link label. Thus, whenever a mouse hangs over it, a person knows that clicking on it causes an action.

    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
      {
        MessageBox.Show("you have clicked a link label");
        //or whatever action you want it to do.
      }
+3
source

For ClickEvent:

You can use an event Label.Clickor TextBox.Clickevent


For an event when TextBoxseveral texts are selected in the text :

Although there is no special event for this. You can use the TextBox.MouseUpfollowing:

private void txtBox_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) 
{
    TextBox txtbx = sender as TextBox;
    if (txtbx != null)
    {
        if (txtbx.SelectionLength > 0)
        {
            string seltxt = txtbx.SelectedText;
            //Do Work Here with 'seltxt' variable!
        }
    }
}
+2

, , , , ?

http://msdn.microsoft.com/en-us/library/system.windows.forms.label_events

Everything that is a Control object in WinForms has a Click event that you can use. Subscribe to this event using a special method and do what you want to do in this case. If you want the look button on the label, I suggest putting a border and moving the cursor, pressing and releasing decorations using the appropriate events.

Hope this helps.

+1
source

They have an event Click.

0
source

All Articles