简体   繁体   English

用户控件用作类

[英]User control used as a class

I have a class and a user control. 我有一个类和一个用户控件。 The user control is supposed to represent the class and contain all its properties. 用户控件应该代表该类并包含其所有属性。 I'm kind of lost on how to handle this problem 我有点不知道如何处理这个问题

all help is greatly appreciated 非常感谢所有帮助

Seems like you need to use data binding. 似乎您需要使用数据绑定。 Create a property typed with your class eg MyClass Data {get; set;} 创建一个用您的类键入的属性,例如MyClass Data {get; set;} MyClass Data {get; set;} , then add new BindingSource and as BindingSource.DataSource set your Data property. MyClass Data {get; set;} ,然后添加新的BindingSource并作为BindingSource.DataSource设置您的Data属性。 Then design your control. 然后设计您的控件。 Do not forget to create new instance of MyClass in constructor. 不要忘记在构造函数中创建MyClass的新实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM