可编辑标签控件
有谁知道我如何创建可编辑标签控件?我需要我的用户能够编辑标签(还可以更改其样式信息的部分),但在网上找不到任何有用的信息。
如有任何帮助,我们将不胜感激,
谢谢
Does anybody know how I could go about creating an Editable Label Control? I need my users to be able to Edit Labels (Also change parts of its style info), but have found no helpful info anywhere online.
Any help at all is appreciated
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以创建自定义控件(需要一些工作)。该控件内部可以有一个标准标签控件,当用户单击该标签(或以某种方式进入编辑模式)时,您可以实例化一个文本框控件并显示标签控件所在的位置。因此,用户会产生标签控件被“转换”为文本框的错觉。用户可以在文本框中编辑标签文本,编辑完成后,您所要做的就是隐藏文本框并将更改应用到标签文本。
如果您还需要编辑样式,则必须显示一个包含所有可编辑设置的面板,而不是一个文本框。
You can create a custom control (requires some work). The control can have a standard label control internally and when the user clicks the label (or goes to the editing mode somehow) you can instantiate a textbox control and show it where the label control was. So the user would get the illusion of the label control being "converted" to a textbox. The user can edit the label text in the textbox and when the editing finished, all you have to do is hide the textbox and apply the changes to the label text.
If you need to edit styles as well, you will have to display a panel with all the editable settings on it instead of a one single textbox.
您可以简单地使用 TextBox 控件,当您需要它们时无法对其进行编辑。只需将其 readOnly 属性设置为 true 即可。
祝你今天过得愉快
you can simply use TextBox control and when you need them not be able to edit it. just turn it's readOnly property to true.
Have a nice day
间接地做到这一点。
例如,注册双击事件并显示带有文本框的无边框表单,用户可以在其中输入新名称。示例:
LabelEditor
表单
Make it indirectly.
E.g. register the double click event and show a borderless form with a TextBox, where the user can enter the new name. Example:
LabelEditor
Form
如果您还想提供编辑样式属性的可能性,您可以使用 窗体上的 PropertyGrid 控件(与 Visual Studio 中用于编辑控件属性的控件相同)。
If you want to give the possibility to edit style properties as well, you might use a PropertyGrid control on your form (the same you use from Visual Studio to edit the controls' properties).