如何用C#做类似Delphi的框架?
一点背景知识:我是一名Delphi程序员,正在重新学习C#(最初是在学校学习的,直到最近才几乎没有接触过),并且正在尝试将我的一些Delphi概念转移过来。
目前的情况是,我需要创建一个应用程序,该应用程序可以根据位置、需要等使用类似数据控件的变量列表中的数据,并且为了在 Delphi 中显示该信息,我只需使用滚动框和框架。我可以轻松地用 C# 面板类替换滚动框,但我没有找到任何可以使用的东西来告诉我如何创建在面板内使用的框架类。我所能找到的只是一些用于网络开发的东西。
谁能为我指明学习 C# 框架等效项的好方向?谢谢。
编辑:
对于非Delphi程序员来说,框架是一个类似表单的控件,允许在其上放置其他控件(按钮、框、网格等),然后框架本身用作表单上的控件以减少代码- 重用,因为所有框架都具有类似的功能并简化开发。有关(可能更好)更深入的描述,请参阅 about.com 或 Delphi 基础知识 说明。
Slight bit of background: I'm a Delphi programmer re-learning C# (learned in school originally, haven't hardly touched until recently), and am trying to get some of my Delphi concepts transferred over.
The current situation is, I need to create an application that can use data from a variable list of similar data controls depending on location, need, etc. and in order to display that information in Delphi, I would simply use a scroll box and frames. The scroll box I can easily replace with the C# panel class, but I'm not finding anything I can use that will tell me how to create my frame class for use inside the panel. All I can find is some stuff for web development.
Can anyone point me in a good direction for learning the C# frame equivalent? Thanks.
EDIT:
For non-Delphi programmers, a frame is a form-like control that allows other controls (buttons, boxes, grids, etc) to be placed on it, then the frame gets used as a control itself on a form to reduce code-reuse as all frames do similar functionality and streamline development. For a (probably better) more in-depth description, see about.com's or Delphi Basics descriptions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对我来说听起来像是一个用户控件。
以下是一些教程:
WPF
WinForms
Sounds like a User Control to me.
Here are some tutorials:
WPF
WinForms
使用过 Delphi 和 .Net 后,我认为 UserControl< /a> 是等效的。它是一个容器,您可以向其中添加控件,然后将其添加到项目中的其他窗体。
Having used both Delphi and .Net, I think a UserControl is the equivalent. It's a container that you can add controls to, and then add to other forms in the project.
您需要创建一个扩展Panel 类的自定义控件,然后重复该自定义控件。
You need to create a custom control that extends the Panel class and then repeat that custom control.
我不熟悉 Delphi,但你所描述的听起来有点像 WPF FlowDocument,或相关控件之一。
I'm not familiar with Delphi, but what you describe sounds a bit like a WPF FlowDocument, or one of the related controls.
Any Panel 提供与Delphi 的Frame(包含其他控件的复合体)相同的功能。
要封装和重用具有特定子项的面板,您需要编写一个自定义类(WinForms 中的自定义控件(如 Payton 提到的),或者更好的是 WPF 中的新控件)。
许多年前我也使用 Delphi 进行编程,我强烈建议使用 WPF 而不是 WinForms,特别是如果您熟悉 HTML 或 XML 或者您需要编写动态或面向数据的应用程序。
Any Panel provides the same functionality as Delphi's Frame (a composite containing other controls).
To encapsulate and reuse a panel with specific children, you need to write a custom class (custom control (as Payton mentioned) in WinForms or better yet a new Control in WPF).
I also programmed in Delphi many years ago and I highly recommend using WPF and not WinForms, especially if you are familiar with HTML or XML or you need to write dynamic or data oriented applications.