How to add button to textbox?

前端 未结 5 1734
死守一世寂寞
死守一世寂寞 2021-01-16 16:35

I\'m trying to make a TextBox with a button on the right side. My code:

public partial class TextBoxButton : TextBox
{
    [Category(\"Button\")]
    [Descri         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-01-16 17:17

    You have to tell the designer that it should also serialize the properties of the button:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public Button Button {
        //...
    }
    

    The default is Hidden so none of the button properties would be written to the Designer.cs file. Setting, say, the Text property works in the designer but the property value is lost after you start the app or reload the form.

提交回复
热议问题