How to handle Form caption right click

后端 未结 6 877
感情败类
感情败类 2021-01-07 10:09

I\'d like a context menu on the caption bar right click

any tips/samples pref in c# ?

UPDATE - for various reasons, right click on the form won\'t work becau

6条回答
  •  無奈伤痛
    2021-01-07 10:52

    if you handle the form mouse-click, you can then use the following code:

      private void Dialog_MouseClick(object sender, MouseEventArgs e)
      {
          if (e.Button == MouseButtons.Right)
          {                                
              this.Text = "new caption text";
          }
      }  
    

    But you'll have to make sure that you generate this event for the top-level control on a form. For instance if you have a group box on the form, it will receive the mouse-click events rather than the form itself, for the areas of the form that are under the group box.

提交回复
热议问题