DevExpress WinForm拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案。DevExpress WinForm能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!

在打开主应用程序表单之前,开发人员可能需要在代码中执行某些操作。例如要启用DirectX硬件加速,开发人员需要在创建应用程序表单之前调用WindowsFormsSettings.ForceDirectXPaint方法。

本文将为大家演示在使用C#和Visual Basic开发项目时,可以将应用程序初始化代码放置在何处。如果您是一个Visual Basic开发人员,可以根据需求选择下面列出方法当中的一种。

获取DevExpress 最新版下载

C#示例

对于C#项目,在Solution Explorer中找到Program.cs文件,该文件包含void Main()过程,开发人员可以在Application.Run方法调用之前在其中添加自定义代码。

C#

using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;namespace WindowsFormsApplication1 {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
//Add your code here
WindowsFormsSettings.ForceDirectXPaint();
WindowsFormsSettings.EnableFormSkins();Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Visual Basic示例 - 方法1

使用这种方法,开发人员可以创建一个Main函数并将其设置为应用程序的入口点。

1. 在Solution Explorer中右键单击您的项目,然后在上下文菜单中选择Properties。

2. 取消选中Enable application framework,然后在Application选项卡中将Startup object设置为Sub Main。

3. 切换到主窗体的代码编辑器,手动将以下Shared Sub Main过程添加到窗体类中:

VB.NET

Public Class Form1
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1) 'Specify the startup form
End Sub
End Class

4. 在Application.Run方法调用之前插入要执行的代码。

VB.NET

Public Class Form1
Shared Sub Main()
'Add your code here
DevExpress.XtraEditors.WindowsFormsSettings.ForceDirectXPaint()
DevExpress.XtraEditors.WindowsFormsSettings.EnableFormSkins()Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1) 'Specify the startup form
End Sub
End Class

Visual Basic示例 - 方法2

通过这种方法,您可以订阅应用程序的Startup事件来执行自定义操作。

1. 在Solution Explorer中右键单击您的项目,然后在上下文菜单中选择Properties。

2. 在Application选项卡中单击View Application Events按钮。

3. 订阅打开的ApplicationEvents.vb文件中的Startup事件。

4. 在生成的Startup事件处理程序中插入要执行的代码。

VB.NET

Imports DevExpress.XtraEditors
Imports Microsoft.VisualBasic.ApplicationServicesNamespace My
' The following events are available for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication
Private Sub MyApplication_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
'Add your code here
WindowsFormsSettings.ForceDirectXPaint()
WindowsFormsSettings.EnableFormSkins()
End Sub
End Class
End Namespace

UI控件DevExpress WinForm新手指南——如何在应用启动时执行操作相关推荐

  1. 界面控件DevExpress WinForm中文教程 - 如何使用模板库构建类Office UI?

    DevExpress WinForm拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案.DevExpress WinForm能完美构建流畅.美观且易于使用的应用程 ...

  2. C# Winform 跨线程更新UI控件常用方法汇总(多线程访问UI控件)

    概述 C#Winform编程中,跨线程直接更新UI控件的做法是不正确的,会时常出现"线程间操作无效: 从不是创建控件的线程访问它"的异常.处理跨线程更新Winform UI控件常用 ...

  3. C#线程操作UI控件

    在写winform程序时候,如果时间长的操作不用线程操作.那么会卡死UI,点击界面就体现为未响应.为此需要对耗时操作用线程处理,比如检验的监听程序就是一个死循环,不停检查文件夹或数据库又没有数据,然后 ...

  4. VCL界面控件DevExpress VCL发布v20.2.6

    DevExpress技术交流群3:700924826      欢迎一起进群讨论 DevExpress VCL Controls是Devexpress公司旗下最老牌的用户界面套包,所包含的控件有:数据 ...

  5. 界面控件DevExpress ASP.NET新主题——Office 365暗黑主题的应用

    DevExpress ASP.NET Web Forms Controls拥有针对Web表单(包括报表)的110+种UI控件,DevExpress ASP.NET MVC Extensions是服务器 ...

  6. iOS SwiftUI篇-2 UI控件 Text Button Image List

    iOS SwiftUI篇-2 UI控件 Text Button Image List Text 显示文本,相当于UILabel import SwiftUIstruct TextContentView ...

  7. UI控件无法响应点击等事件的探索

    2019独角兽企业重金招聘Python工程师标准>>> UI控件无法响应点击等事件的探索 一.响应者链 关于响应者链,有如下一段介绍:每一个应用有一个响应者链,我们的视图结构是一个N ...

  8. RxSwift UI控件扩展

    RxSwift UI控件扩展 最好的示例是参考RxCocoa查看类似的属性如何扩展Rx化的. 为了配合RxSwift的绑定关系,RxCocoa提供简单的基于Cocoa控件的扩展,但是很少,比如Labe ...

  9. UI控件库分享:DWZ(j-UI)、LigerUI、Linb

    DWZ(j-UI): 在线演示地址:http://demo.dwzjs.com 在线文档:http://demo.dwzjs.com/doc/dwz-user-guide.pdf DWZ框架Ajax开 ...

最新文章

  1. ArUco与AprilTag简介
  2. Codeforces 352B - Jeff and Periods
  3. NB-IOT终端技术新突破 中兴微电子加快IoT布局
  4. mysql导入csvnull,MySQL Workbench从CSV导入NULL
  5. sklearn分类器算法:逻辑回归及案例分析
  6. VC遍历窗口上的控件
  7. PHP openssl加密扩展使用总结
  8. 你的工资基础决定你的前途
  9. Ffmpeg实例,为视频添加一个循环播放的背景音乐(混声)
  10. Linux如何安装/卸载.deb文件(保姆级教程)
  11. ps4怎么用html,ps4改dns教程 ps4怎么设置dns
  12. U盘格式化后容量变小了怎么恢复教程
  13. 统计元音(函数专题)
  14. 2016.7.14 noip2014模拟题 LGTB的日常~(自己乱安的名字hhh
  15. android 画布心形,用CANVAS实现的心形动画效果
  16. 佳博80250打印机怎么看打印机IP
  17. CPU平均负载过高检查(iowait负载高)
  18. 新的地址http://www.civilianshop.com/blog/
  19. 趣出行APP被指存在四项涉嫌隐私不合规问题,仍借虚拟货币宣传?
  20. 智慧应急解决方案-最新全套文件

热门文章

  1. js+json实现哔哩哔哩番剧时间表
  2. 国密SSL证书正式上线,知道创宇云防御助力金融和重要领域完成国密升级改造...
  3. 《底层逻辑》 思维导图
  4. kuberneters集群发布内部服务详解
  5. 关于qt 实现laber上面的文字滚动
  6. 我的世界服务器修改nbt,我的世界NBT教程 关于NBT作用与内容介绍
  7. 整理的一些关于手机拍照技巧的内容
  8. 有哪些国外便宜虚拟主机适合个人建站呢
  9. ios开发者联系方式
  10. 使用Windows自带工具WINSat给硬盘测速