public class CustomFormPainter : FormPainter
{
public CustomFormPainter(Control owner, DevExpress.Skins.ISkinProvider provider)
: base(owner, provider)
{
}
protected override void DrawText(DevExpress.Utils.Drawing.GraphicsCache cache)
{ string text = Text;
if (text == null || text.Length == || TextBounds.IsEmpty) return;
using (AppearanceObject appearance = new AppearanceObject(GetDefaultAppearance()))
{
appearance.TextOptions.Trimming = Trimming.EllipsisCharacter;
appearance.TextOptions.HAlignment = HorzAlignment.Center;
appearance.Font = new Font(appearance.Font.Name, , FontStyle.Bold, appearance.Font.Unit, appearance.Font.GdiCharSet, appearance.Font.GdiVerticalFont);
if (AllowHtmlDraw)
{
DrawHtmlText(cache, appearance);
return;
}
Rectangle r = RectangleHelper.GetCenterBounds(TextBounds, new Size(TextBounds.Width, CalcTextHeight(cache.Graphics, appearance)));
DrawTextShadow(cache, appearance, r);
cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
}
}
}
这样用
    public partial class frmMain : DevExpress.XtraEditors.XtraForm
{
static frmMain()
{
SkinManager.EnableFormSkins();
}
public frmMain()
{
InitializeComponent();
}
protected override FormPainter CreateFormBorderPainter()
{
return new CustomFormPainter(this, LookAndFeel);
}
}

 

设置XtraForm标题居中的更多相关文章

  1. 不使用setCustomView,设置ActionBar标题居中

    仅供参考,有太多自定义标题栏需求时,还是建议使用setCustomView https://blog.csdn.net/chiceT/article/details/50455358

  2. easyui中datagrid标题居中内容居左实现方式

    easyui中的datagrid使用起来,确实还是挺轻巧方便,但是其中也有不少的问题,尤其遇到客户的一些特殊的需求时往往实现得不是很好.这个时候就需要我们自己动手来修改easyui的源码了.easyu ...

  3. 2016word多级列表 一级标题居中后偏左

    一.如下图所示,定义好多级列表之后设置标题,但是发现标题居中后偏左. 二.选择多级列表,设置居左对齐

  4. DataGridView列标题居中,内容居中

    //列标题居中 dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleC ...

  5. VBA在WORD中给表格外的字体设置为标题

    使用VB可以将表外的字体设置标题字体实际操作如下: VB代码如下: Sub oliver_1() Selection.EndKey Unit:=wdStory '光标移到文末 To ActiveDoc ...

  6. Android Navigation Drawer,自定义ActionBar(标题居中)

    整个示例都是改造自 Google Android Training 中的 NavigationDrawer 示例(http://developer.android.com/training/imple ...

  7. 设置TextView文字居中

    有2种方法可以设置TextView文字居中: 一:在xml文件设置:android:gravity="center" 二:在程序中设置:m_TxtTitle.setGravity( ...

  8. WPS怎样设置多级标题(如四级标题)

    WPS期初,乍一看最多只能设置三级标题. 怎样设置四级以上标题呢? 这里以设置四级标题为例: 点击‘视图’->'大纲', 假如,现在2.3.3这一行是三级标题: 在下拉框里选择‘4级’就可以了. ...

  9. 【转】设置TextView文字居中

    原文网址:http://blog.csdn.net/lanpy88/article/details/6616924 有2种方法可以设置TextView文字居中: 一:在xml文件设置:android: ...

随机推荐

  1. MySQL数据库9 - 日期与时间函数

    一 日期和时间函数 函数的概念:按指定格式输入参数,返回正确结果的运算单元 1. 返回当前日期:curdate() current_date() current_date()+0可以将当前日期转换为数 ...

  2. Spring事务传播机制&隔离级别

    一.Propagation (事务的传播属性) Propagation : key属性确定代理应该给哪个方法增加事务行为.这样的属性最重要的部份是传播行为.有以下选项可供使用:PROPAGATION_ ...

  3. jquery中的DOM事件绑定与解绑

    在jquery事件中有时候有的事件只需要在绑定后有效触发一次,当通过e.target判断触发条件有效触发后解除绑定事件,来避免多次无效触发和与未知情况造成冲突. 这时候就要用到了jquery中的事件绑 ...

  4. 重写ajax方法实现异步请求session过期时跳转登录页面

    jQuery(function($){ // 备份jquery的ajax方法 var _ajax=$.ajax; // 重写ajax方法, $.ajax=function(opt){ var _suc ...

  5. WCF Restful 服务器配置文件

    <?xml version="1.0" encoding="utf-8"?> <configuration> <configSec ...

  6. Linux 知识框架

    Linux要点 一.Linux的基本要求 1. 掌握至少50个以上的常用命令. 2. 熟悉Gnome/KDE等X-windows桌面环境操作 . 3. 掌握.tgz..rpm等软件包的常用安装方法 4 ...

  7. A Simple Problem with Integers_树状数组

    Problem Description Let A1, A2, ... , AN be N elements. You need to deal with two kinds of operation ...

  8. Azure自动化实例: 复制blog用于备份

    在Azure 自动化:使用PowerShell Credential连接到Azure, 之后, 我在项目中遇到了实现blog备份的任务, 现将其作为一个实例写下来: 1. 首先,创建自动化帐户, 在资 ...

  9. Sunny-Code Beta版总结会议

    时间:2015-6-12 地点:基教601 参会人员:Sunny-Code全体成员 设想和目标 我们的软件要解决什么问题?是否定义得很清楚? 我们打算做一款集成小蝴蝶功能.Ip快速修改功能.WiFi共 ...

  10. overflow:hidden清楚浮动的影响

    在网页布局中有时会遇到这种情况: 如果左边用<dt>,右边用<dd>,放在一行显示,<dt>要设置float:left,这个应该都知道,问题是,第一行这样做没有问题 ...