VB.Net 自定义控件

发布于 2024-08-25 23:55:53 字数 777 浏览 2 评论 0原文

这可能是基本问题,但是我对一些 .Net Concpets 感到困惑。
我正在尝试在 VB.net 中创建一个“数据浏览器”。

  • 类似于网络浏览器,但是每个 数据浏览器中的选项卡是以下视图 一些数据(来自数据库或平面 文件)而不是网页。
  • 每个选项卡上的 UI 主要是 相同的。
  • 列表框(显示数据类型等), 一个文本框(您可以在其中创建 过滤器)和一个 DataGridView,一个 数据源选择器等
  • 唯一会改变的 每个选项卡都可能有一个 自定义“查看器”。大多数情况下 (取决于数据源),这 将是数据网格,但是在 其他情况下这将是 树控件。

通过阅读.Net文档,我似乎需要创建一个自定义控件(MyDataBrowser),该控件由一个带有所有常见控件(查看器除外)的面板组成。每次用户说“新选项卡”时,都会创建一个新选项卡页并添加此 MyDataBrowser 控件。MyDataBrowser 控件将包含一些功能,然后能够根据手头的数据创建适当的查看器。

如果这是建议的路线,那么创建 MyDataBrowser 控件的最佳方法是什么

  • (A)这是自定义控件库吗?
  • (B) 这是继承形式吗?
  • (C) 这是继承用户吗 控制?

我假设我必须创建一个 .DLL 并添加作为参考。 对此的任何指示将不胜感激。

  1. 自定义控件有它的吗 自己的财产(我想 从配置中保存/加载它们 文件)。
  2. 是否可以添加一个 对此的背景工作者 自定义控件?

谢谢。

This might be basic question, however I am confused on some .Net Concpets.
I am trying to create a "Data Browser" in VB.net.

  • Similar to a Web Browser however each
    Tab in the Data Browser is a view of
    some Data (from a database or flat
    files) not a webpage.
  • The UI on each Tab is mostly the
    same.
  • A list Box (showing datatypes, etc),
    a TextBox (where you can create a
    filter), and a DataGridView, a
    DataSource Picker, etc.
  • The only thing that would change on
    each tab is that there could be a
    custom "Viewer". In most cases
    (depending on the datasource), this
    would be the datagrid, however in
    other cases it would be a
    treecontrol.

From reading through the .Net documents, it appears that I need to Create a Custom Control (MyDataBrowser) Consisting of a Panel with all the common Controls (except the viewer). Every time the user says "New Tab", a new tabpage is created and this MyDataBrowser Control is added, The MyDataBrowser control would contain some function that was able to then create the approriate viewer based on the data at hand.

If this is the suggested route, how is the best way to go about creating the MyDataBrowser Control

  • (A) Is this a Custom Control Library?
  • (B) Is this an Inhertited Form?
  • (C) Is this an Inherrited User
    Control?

I assume that I have to create a .DLL and add as a reference.
Any direction on this would be appreciated.

  1. Does the custom Control have its
    own properties (I would like to
    save/load these from a configuration
    file).
  2. Is it possible to add a
    backgroundworker to this
    customcontrol?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热血少△年 2024-09-01 23:55:53

您需要创建一个用户控件。

MSDN 上有一个演练详细介绍了这一点 - 演练:创作复合控件使用 Visual Basic

话虽如此,对于您的具体问题:

  1. 是的。它有自己的属性(由您定义)。
  2. 您可以将一个(或多个)BackgroundWorker 添加到UserControl。

至于部署 - 通常,您会将其放在类库(生成 DLL)中,并在应用程序中引用它,但这取决于您。 UserControl 也可以直接添加到您的应用程序中。

You'll want to make a UserControl.

There is a walkthrough on MSDN that covers this in detail- Walkthrough: Authoring a Composite Control with Visual Basic.

That being said, for your specific questions:

  1. Yes. It has its own properties (which you define).
  2. You can add a BackgroundWorker (or multiple ones) to a UserControl.

As for deployment - typically, you'd have this in a class library (which makes a DLL), and reference that within your applications, but that is up to you. The UserControl can also just be added directly to your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文