Add a badge to a C# winforms control

前端 未结 3 1618
暖寄归人
暖寄归人 2020-12-11 13:24

When writing in CSS I can add a class of \"badge\" and get what I want. A small number near a button or tab with some styling to it, to show that this control has pending in

3条回答
  •  时光说笑
    2020-12-11 14:11

    Really the easiest and best way to achieve this is to create a new customized UserControl. Just add a button and insert a label over it on the right. Then add getters and setters for the controls inside you new UserControl. Here's an example of get/set to configure the button's notification:

    public String ButtonNotification {
       get { return yourUserControlLabel.Text; }
       set {
             if (value == null || value == "") { yourUserControlLabel.Visibility = Hidden; }
             else { yourUserControlLabel.Visibility = Visible; }
    
             yourUserControlLabel.Text = value;
       }
    }
    

    Then you can customize the label's visibility and other properties with the getters/setters.

提交回复
热议问题