WinForms Controls > Examples > How to: Add New XtraForm, RibbonForm and XtraUserControl to Your Proj

 

This topic shows how you can add a new XtraForm, RibbonForm or XtraUserControl to your project.

如何添加XtraForm、RibbonForm或XtraUserControl到项目

To learn how to convert an existing Form/UserControl to the XtraForm/RibbonForm/XtraUserControl, see How to: Convert Form to XtraForm (RibbonForm), and UserControl to XtraUserControl.

学习如何将已经存在的Form/UserControl 转换为XtraForm/RibbonForm/XtraUserControl,看:

 

Add New XtraForm, RibbonForm, XtraUserControl 添加新XtraForm, RibbonForm, XtraUserControl

  1. Switch to the Solution Explorer and right-click your project name. Select the Add->New Item... menu option.切换到解决方案浏览器,右击项目名称,选择添加→新建项。。。菜单项

  2. A dialog will open that lists available templates for creating new items.打开的对话框列出了创建新项可用的模板。

  3. Select the required item to create a new DevExpress Form or UserControl.选择创建DevExpress Form或UserControl需要的项。

    - DevExpress Form - creates a new XtraForm. DevExpress Form-创建一个新的XtraForm

    - DevExpress User Control - creates a new XtraUserControl. DevExpress User Control 创建一个新的XtraUserControl.

    - DevExpress RibbonForm - creates a new RibbonForm. DevExpress RibbonForm -创建新的RibbonForm

How to: Convert Form to XtraForm (RibbonForm), and UserControl to XtraUserControl

如何:转换Form为XtraForm(RibbonForm)和UserControl到XtraUserControl

If you need to transform an existing Form or UserControl to a DevExpress XtraForm, RibbonForm or XtraUserControl, simply modify the code that declares your Form/UserControl. Simply replace the Form's/UserControl's ancestor with the corresponding DevExpress class.

如果需要转换已经存在的Form或UserControl为DevExpressXtraForm,RibbonForm or XtraUserControl,简单的修改声明你窗体/用户控件UserControl的代码即可。简单的用相对于的DevExpress类替换Form或UserControl基类。

Before proceeding, ensure that DevExpress.Data, DevExpress.Utils andDevExpress.XtraEditors libraries are added to the References section of your project. To use a RibbonForm, add theDevExpress.XtraBars library as well.

处理之前,保证DevExpress.Data, DevExpress.Utils andDevExpress.XtraEditors库添加到了项目的引用部分。为使用RibbonForm,添加DevExpress.XtraBars库引用。

This example shows how to convert a standard form to XtraForm. Conversion to RibbonForm and XtraUserControl is performed in the same manner. 本例演示如何转换标准窗体到XtraForm。到RibbonForm和XtraUserControl实现操作与此一样。

1、译者住:首先需要添加对Xtra控件的引用,如下,项目的引用上右击,添加引用,选择.NET页,找到DevExpress.Data, DevExpress.Utils andDevExpress.XtraEditors,用Ctrl+鼠标多选要添加的引用,然后点击确定,

 

 

2、Open a file that contains a form's declaration: in C# - a form's declaration can be found in the Form1.cs file, while in Visual Basic - the form is in the Form1.Designer.vb file). The form is declared as follows.打开包含窗体声明的文件:C#- 窗体声明在文件Form1.cs,

C#
VB
public partial class Form1 : Form {
    //... 
}
 

 

3、Rewrite this declaration as follows.按如下重写代码

C#
VB
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
   //... 
}
 

4、Then rebuild the project. 重新生成项目。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
In .NET 6 and later versions, the `System.Windows.Forms` namespace is not included in the default installation of WPF applications. However, you can still use the `FolderBrowserDialog` class in your WPF application by adding a reference to the `System.Windows.Forms` NuGet package and using the `System.Windows.Forms.Integration` namespace. Here are the steps to use `FolderBrowserDialog` in .NET 6 WPF: 1. Add a reference to the `System.Windows.Forms` NuGet package in your WPF project. 2. Add the following using statements to the top of your code file: ```csharp using System.Windows.Forms; using System.Windows.Forms.Integration; ``` 3. In your code, create a `FolderBrowserDialog` object and use the `ShowDialog` method to display the dialog box: ```csharp FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { // do something with the selected folder } ``` 4. If you want to use the `FolderBrowserDialog` in a WPF window or page, you can use the `WindowsFormsHost` control to host the dialog box: ```xml <Window xmlns:winforms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" ...> <Grid> <winforms:WindowsFormsHost> <forms:FolderBrowserDialog x:Name="folderDialog" /> </winforms:WindowsFormsHost> </Grid> </Window> ``` Then, you can use the `ShowDialog` method to display the dialog box: ```csharp if (folderDialog.ShowDialog() == DialogResult.OK) { // do something with the selected folder } ``` Note that you will also need to add a reference to the `WindowsFormsIntegration` assembly in your WPF project.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值