iewOptionsBehavio
r.Editable = Tr
OptionsColumn.AllowEdit = Tr
OptionsColumn.ReadOnly = Tr
可编辑:
ColumnViewOptionsBehavio
r.Editable =
Tr
OptionsColumn.AllowEdit = Tr
OptionsColumn.ReadOnly = False
8.模板列的设置:
到Columns中,在他的属性中找到ColumnEdit.
以LookUpEdit为例:
首先从Designer左边菜单In-Place Editor
Repository中添加LookUpEdit.取名为Re1.然后.在他的Columns属性中添加3列.Caption依次为:编号,姓名,性别.FieldName依次为:FID,FNAME,FSEX.然后将Re1的NullText设置成空.
AutoSearchColumnIndex属性设置为2.ImmediatePopup属性设置为Tr.
SearchMode设置为OnlyInPopup.
然后将这个模板列附加到我们上面提到的列1(也就是将列1的ColumnEdit属性设成Re1)
最后我们还要在代码里面给Re1绑定数据源和显示项.
Re1.DataSource = DALUse.Qry('select fid,fname,fsex from d
l').Tables[0];
Re1.DisplayMember = 'FSEX';
Re1.ValMember = 'FNAME';
9.设某一列文字和标题局中显示
gridView1.Columns[0].AppearanceHeader.TextOptions.HAlignment =
DevExpress.Utils.HorzAlignment.Center;
gridView1.Columns[0].AppearanceCell.TextOptions.HAlignment =
DevExpress.Utils.HorzAlignment.Center;
10.去掉某一列上面的自动筛选功能(Filter)
gridView1.Columns[0].OptionsFilter.AllowAutoFilter
= false;
gridView1.Columns[0].OptionsFilter.AllowFilter =
false;
gridView1.Columns[0].OptionsFilter.ImmediateUpdateAutoFilte
r
= false;
11.设置冻结列(左冻结)
gridView1.Columns[0].Fixed=
DevExpress.XtraGrid.Columns.FixedStyle.Left;
12.得到单元格数据(0行0列)
string ss=gridView1.GetRowCellDisplayText(0,
gridView1.Columns[0]);
string ss = gridView1.GetRowCellVal(0,
gridView1.Columns[0]);
13.设置单元格数据(将0行0列的单元格赋值123)
gridView1.SetRowCellVal(0, gridView1.Columns[0],
'123');
13.手动添加dev的列
DevExpress.XtraGrid.Columns.GridColumn Col1=new
DevExpress.XtraGrid.Columns.GridColumn ();
Col1.FieldName='FID';
Col1.Visible=tr;
Col1.VisibleIndex=gridView1.Columns.Count;
gridView1.Columns.Add(Col1);
14.设置自动增加的行号,需要先添加给gridview添加事件CustomDrawRowIndicator
private void
gridview_CustomDrawRowIndicator(object sender,
DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEv
entArgs
e)
{
if
(e.Info.IsRowIndicator && e.RowHandle >= 0)
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
15.删除: (修改了dgvdel里的datagridviewdel方法)
p lic static void
datagridviewdel_Dev(DevExpress.XtraGrid.Views.Grid.GridView
Mydgv)
{
if
(MessageBox.Show('你确定要删除选中的记录吗?', '删除提示', MessageBoxButtons.YesNo,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false)
== DialogResult.Yes)
{
int iSelectRowCount =
Mydgv.SelectedRowsCount;
if (iSelectRowCount > 0)
{
Mydgv.DeleteSelectedRows();
}
}
}
16. 新增: (对于新增,其本身的AddNewRow方法就可以做到)
private void btn_add_Click(object sender,
EventArgs e)
{
gridView1.AddNewRow();
}
具体如果对于新加行还有什么特别的设置,可以在它gridView1_InitNewRow事件中填写:
private void gridView1_InitNewRow(object
sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
ColumnView View =
sender as ColumnView;
View.SetRowCellVal(e.RowHandle, View.Columns[0],
gridView1.GetRowCellVal(gridView1.GetRowHandle
(gridView1.RowCount - 2), gridView1.Columns[0]));
//复制最后一行的数据到新行
View.SetRowCellVal(e.RowHandle,
View.Columns[1],
gridView1.GetRowCellVal(gridView1.GetRowHandle
(gridView1.RowCount - 2), gridView1.Columns[1]));
//复制最后一行的数据到新行
}
17. 保存
(第三方控件提供的RefreshData和RefreshDataSource方法对于保存数据都不好使,最后还是使用了Dgvsave的
datagridviewsave方法,用这个方法就可以)
18.特效:gridcontrol中有5种view
型式,普通的是gridview,然后分别为cardview、BandedView、Advanced BandedView、
LayoutView;共5种。
1)、view组中把OptionView下的viewmode
设置成“Carousel”就达到这种“旋转木马”式的gridcontrol view 特效了
2)、layoutView1.OptionsCarouselMode.PitchAngle
这个属性决定“旋转木马”的pitch angle 螺距角; 螺旋角; 螺旋升角; 俯
仰角; 倾角; 节锥半角
3)、Roll Angle 属性决定着 倾侧角度
4)、指定数据源,显示数据:
//显示数据
private
void showData(List list)
{
DataTable dt = new
DataTable('OneEmployee');
dt.Columns.Add('Caption',
System.Type.GetType('System.String'));
dt.Columns.Add('Department',
System.Type.GetType('System.String'));
dt.Columns.Add('PhotoName',
System.Type.GetType('System.Byte[]'));
for (int i = 0; i < list.Count;
i++)
{
DataRow dr
= dt.NewRow();
dr['Caption'] = list[i].Name;
dr['Department'] = list[i].Department;
string
imagePath = @'D:/C#/photos/' + list[i].PhotoPath;
dr['PhotoName'] = getImageByte(imagePath);
dt.Rows.Add(dr);
}
gridControl1.DataSource = dt;
}
//返回图片的字节流byte[]
private
byte[] getImageByte(string imagePath)
{
FileStream files = new
FileStream(imagePath, FileMode.Open);
byte[] imgByte = new byte [files.Length
];
files.Read(imgByte, 0,
imgByte.Length);
files.Close();
return imgByte;
}
19.检查数据的有效性
在gridview的ValidateRow事件中加入检查代码:
#region 检查数据
private void gridView1_ValidateRow(object sender,
ValidateRowEventArgs e)
{
GridView view = sender as
GridView;
view.ClearColumnErrors();
if (view.GetRowCellVal(e.RowHandle,
'ReceiveDate') == DBNull.Val)
{
e.Valid =
false;
view.SetColumnError(view.Columns['ReceiveDate'],
'必须指定日期');
}
}
#endregion
调用gridview.UpdateCurrentRow()方法执行检查
最常用的DevExpress Winform 4个代码片段:
一 、GridControl的删除操作
private void rILinkEditInfoDel_Click(object sender,
EventArgs e)
{
if
(XtraMessageBox.Show('请确定是否删除当前记录?', '警告', MessageBoxButtons.YesNo,
MessageBoxIcon.Warning) == DialogResult.Yes)
{
DataRow row = gvInfos.GetDataRow(gvInfos.FocusedRowHandle);
delByCode(row['Code'].ToString());
XtraMessageBox.Show('操作成功!');
}
}
二、绑定非数据表中列
Hashtable ht = new Hashtable();
private void gridView6_CustomUnboundColumnData(object sender,
DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArg
s
e)
{
GridView View = sender as
GridView;
if (e.RowHandle >= 0)
{
object needAlert = View.GetRowCellVal(e.RowHandle,
View.Columns['needAlert']);
if
(needAlert != null & needAlert != DBNull.Val &&
needAlert.ToString().Trim() != '0' &
View.GetRowCellVal(e.RowHandle, View.Columns['Val']) !=
DBNull.Val)
{
decimal AverVal =
Convert.ToDecimal(View.GetRowCellVal(e.RowHandle,
View.Columns['Val']));
object MinVal =
View.GetRowCellVal(e.RowHandle, View.Columns['MinVal']);
object MaxVla =
View.GetRowCellVal(e.RowHandle, View.Columns['MaxVal']);
if (MinVal != DBNull.Val &
MinVal != null & MaxVla.ToString() != '' & MaxVla !=
DBNull.Val && MaxVla != null & MaxVla.ToString() !=
'')
{
decimal gridColumn2 =
Convert.ToDecimal(View.GetRowCellVal(e.RowHandle,
View.Columns['MinVal']));
decimal gridColumn1 =
Convert.ToDecimal(View.GetRowCellVal(e.RowHandle,
View.Columns['MaxVal']));
if
(gridColumn2 > AverVal || AverVal > gridColumn1)
{
if (!ht.ContainsKey('pic'))
ht.Add('pic', GetImage(1));
e.Val = ht['pic'];
}
}
}
}
}
///
/// 由资源文件获取图片
///
///
///
byte[] GetImage(int key)
{
Image img =
DevExpress.Utils.Controls.ImageHelper.CreateImageFromResources
(string.Format('RiverSys.Resources.{0}.gif',
key.ToString()), typeof(RiverInfos).Assembly);
return
DevExpress.XtraEditors.Controls.ByteImageConverter.ToByteArray(img,
ImageFormat.Gif);
}
///
/// 动态根据条件设置行样式
///
///
///
private void gridView6_RowStyle(object sender,
DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
GridView View = sender as
GridView;
if (e.RowHandle >= 0)
{
object needAlert = View.GetRowCellVal(e.RowHandle,
View.Columns['needAlert']);
if
(needAlert != null & needAlert != DBNull.Val &&
needAlert.ToString().Trim() != '0' &
View.GetRowCellVal(e.RowHandle, View.Columns['Val']) !=
DBNull.Val)
{
decimal AverVal =
Convert.ToDecimal(View.GetRowCellVal(e.RowHandle,
View.Columns['Val']));
object MinVal =
View.GetRowCellVal(e.RowHandle, View.Columns['MinVal']);
object MaxVla =
View.GetRowCellVal(e.RowHandle, View.Columns['MaxVal']);
if (MinVal != DBNull.Val &
MinVal != null & MaxVla.ToString() != '' & MaxVla !=
DBNull.Val && MaxVla != null & MaxVla.ToString() !=
'')
{
decimal gridColumn2 = Convert.ToDecimal(MinVal);
decimal gridColumn1 = Convert.ToDecimal(MaxVla);
if
(gridColumn2 > AverVal || AverVal > gridColumn1)
{
e.Appearance.ForeColor =
Color.Red;
e.Appearance.BackColor =
Color.LightGray;
}
}
}
}
}
三、GridControl 中颜色选择控件
private void gvMapColor_CustomUnboundColumnData(object sender,
DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArg
s
e)
{
GridView view = sender as
GridView;
DataView dv = view.DataSource as
DataView;
if (e.IsGetData)
{
string strVal = dv[e.ListSourceRowIndex]['Color'].ToString();
if
(strVal != '')
{
//e.Val =
DevExpress.Utils.StyleLayout.ColorFromString(strVal);
e.Val =
Common.HexToColor(strVal);
}
}
else
{
//Color colorVal =
DevExpress.Utils.StyleLayout.ColorFromString(e.Val.ToString());
Color colorVal = (Color)e.Val;
dv[e.ListSourceRowIndex]['Color'] =
Common.RGB_HEX(colorVal.ToArgb());
}
}
四、关于 GridControl 验证示例
///
/// 初始化GridView,绑定数据
///
///
private void GridViewBindData(string parentId)
{
this.gridView1.Columns.Clear();
this.FDs=
areaSetupActionHelper.getDsRegionByParentId(parentId);
this.gridCArea.DataSource =this.FDs.Tables[0].DefaultView;
this.gridView1.Columns['id'].VisibleIndex =
-1;
this.gridView1.Columns['childCounts'].VisibleIndex = -1;
this.gridView1.Columns['reg_id'].Caption =
'区划编号';
this.gridView1.Columns['reg_name'].Caption
= '区划名称';
this.gridView1.Columns['parent_id'].Caption
= '父区划编号';
this.gridView1.Columns['reg_desc'].Caption
= '区划描述';
this.gridView1.Columns['parent_id'].ImageIndex =1;
this.gridView1.Columns['reg_desc'].ImageIndex = 0;
RepositoryItemTextEdit textEditReg_Id = new
RepositoryItemTextEdit();
textEditReg_Id.Mask.EditMask
=parentId+'//d{2,3}';
textEditReg_Id.Mask.MaskType =
DevExpress.XtraEditors.Mask.MaskType.Regular;
this.gridView1.Columns['reg_id'].ColumnEdit
= textEditReg_Id;
this.gridView1.Columns['reg_desc'].ColumnEdit = new
RepositoryItemMemoExEdit
();
TreeListNode node =
this.treelArea.FocusedNode.ParentNode;
string fid =
node==null?'0':node.GetVal('RegID').ToString().Trim();
DataSet ds =
areaSetupActionHelper.getDsRegionByParentId(fid);
RepositoryItemLookUpEdit
lookParent_Id = new RepositoryItemLookUpEdit
();
lookParent_Id.Columns.Add(new
LookUpColumnInfo('reg_id', 40, '区划编号'));
lookParent_Id.Columns.Add(new
LookUpColumnInfo('reg_name', 40, '区划名称'));
lookParent_Id.DataSource =
ds.Tables[0].DefaultView;
lookParent_Id.ValMember = 'reg_id';
lookParent_Id.DisplayMember =
'reg_id';
this.gridView1.Columns['parent_id'].ColumnEdit =
lookParent_Id;
}
///
/// gridView单元格验证的相关处理程序
///
///
///
private void gridView1_ValidatingEditor(object sender,
DevExpress.XtraEditors.Controls.BaseContainerValidateEdi
torEventArgs
e)
{
if (e.Valid == false&this.gridView1.FocusedColumn.FieldName ==
'reg_id')
{
e.ErrorText =
'区划编号不合法!/n应为父区划编号加2~3位数据组成!';
}
if (this.gridView1.FocusedColumn.FieldName
== 'reg_name')
{
Regex reg=new
Regex(@'[/一-/龥]{1,20}');
Match
m=reg.Match(e.Val.ToString().Trim());
if (m.Length !=
e.Val.ToString().Trim().Length)
{
e.Valid = false;
e.ErrorText =
'区划名称应为汉字/n长度为1至20';
}
}
}
private void gridView1_InvalidValException(object sender,
InvalidValExceptionEvent
Args e)
{
if
(MyDialog.Alert(' 您所填写的内容不符合规则/n 要放弃您刚才对此项所做的更改吗?', '您所编辑的内容不符合规则',
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
DialogResult.Yes)
{
e.ExceptionMode =
ExceptionMode.Ignore;
}
}
///
/// gridView行验证的相关处理程序
///
private void gridView1_ValidateRow(object sender,
DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
{
string regid = this.gridView1.GetRowCellVal(e.RowHandle,
'reg_id').ToString().Trim();
string regName = this.gridView1.GetRowCellVal(e.RowHandle,
'reg_name').ToString().Trim();
if ( regid.Length < 1)
{
e.Valid = false;
this.gridView1.SetColumnError(this.gridView1.Columns['reg_id'],
'请填写区划编号!',
DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
// e.ErrorText =
'区划名称不能为空!';
}
if (regName.Length < 1)
{
e.Valid = false;
this.gridView1.SetColumnError(this.gridView1.Columns['reg_name'],
'区划名称不能为空!',
DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
}
}
private void gridView1_InvalidRowException(object sender,
DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEvent
Args
e)
{
if (e.RowHandle >= 0)
{
if
(this.gridView1.GetRowCellVal(e.RowHandle,
this.gridView1.Columns['reg_id']).ToString().Trim() == '' ||
this.gridView1.GetRowCellVal(e.RowHandle,
this.gridView1.Columns['reg_name']).ToString().Trim() == '')
{
if (MyDialog.Alert('
您所填写的内容不符合规则/n 要放弃您刚才对此项所做的更改吗?', '您所编辑的内容不符合规则',
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
DialogResult.Yes)
{
e.ExceptionMode =
ExceptionMode.Ignore;
}
else
{
e.ExceptionMode =
ExceptionMode.NoAction;
}
}
}
else
{
e.ExceptionMode =
ExceptionMode.Ignore;
}
}
posted @ 2011-10-26 21:11 许海彪 阅读(378) 评论(0)
编辑
汉化DevExpress
posted @ 2011-10-26 21:09 许海彪 阅读(272) 评论(0)
编辑
学习XtraGrid
1.基本grid的用法
1.1
gridControl-->view-->gridView
绑定到grid上的字段可以拖动删除,在任意字段上右键点column chooser 可以将删除的字段添加进来
字段上右键选择实现选定需要的信息和排序
字段上右键选择分组(group by
column),也可以直接将字段拖到上面实现分组
字段上右键选择group by box后可以取消分组栏,(不能实现拖动分组,但可以选择分组)
字段上右键选择best fit可以实现该字段最佳宽度(便于查看)
1.2
gridControl-->view-->cardView
以卡片形式存放数据
可以自己设定过滤选项
1.3
gridControl-->view-->banderGridView
将字段分段显示,前提是给
gridControl先绑定一个dataset
动态绑定的时候不能分段,也不能分行
1.3
gridControl-->view-->advBanderGridView
高级分段显示,动态绑定的字段可以在前台向下拖动后分段,但效果不好,相当于分行显示的样子
1.4 else
可以通过create ner view增加一个view ,但程序只显示你选定的view
zoom的使用
快速上升,也就是选择子项后单独显示(上到最高显示)
1.5 feature browser
-->priview
可以指定在每行中预览的字段
-->filtering 可以自动过滤(optingview.showAutoFiterRow)
1.7 Master-Detail
绑定的问题
首先在gridControl1中指定dataSource 的绑定是主表
然后在level设计器中添加层(retrieve details)
最后用代码绑定:
using (SqlConnection con = new
SqlConnection(SqlHepler.CONN_STRING))
{
//SqlDataAdapter sda1 = new SqlDataAdapter('select * from
Orders',con);
//sda1.Fill(this.northwindDataSet.Orders);
SqlDataAdapter sda2 = new SqlDataAdapter('select * from [Order
Details]',con);
sda2.Fill(this.northwindDataSet.Order_Details);
}
1.8 summary的用法
//If the GridOptionsView.ShowFooter option
is set,
//the summary(of course some else can ) can
be displayed within the footer cell.
gridView1.OptionsView.ShowFooter =
true;
//初始化,也可以不用指定
colOrderID.SummaryItem.FieldName =
'OrderID';
colOrderID.SummaryItem.SummaryType =
DevExpress.Data.SummaryItemType.Count;
2.XtraGrid的打印
借用别人写的一个类
class DevPrint
{
//*********************字段*********************
private
string pageHeaderName='';
private
string pageFooterName='';
private
bool isPrintPage=true;
private
bool isPrintDate=true;
private int
headerLocation=1;
private int
footerLocation=1;
private int
pageLocation=3;
private int
dateLocation=5;
private
bool enableEditPage = true;
private
System.Drawing.Font pageHeaderFont = null;
private
System.Drawing.Font pageFooterFont = null;
private
System.Drawing.Printing.Margins devMargins = null;
private
System.Drawing.Printing.PaperKind devPaperKind =
System.Drawing.Printing.PaperKind.A4;//可以自定义修改纸张
private
DevExpress.XtraPrinting.PageHeaderArea PHA = new
DevExpress.XtraPrinting.PageHeaderArea();
private
DevExpress.XtraPrinting.PageFooterArea PFA = new
DevExpress.XtraPrinting.PageFooterArea();
//*********************字段*********************
//*********************属性*********************
//标题
public
string PageHeaderName
{
get
{
return
pageHeaderName;
}
set
{
pageHeaderName=value;
}
}
//页脚
public
string PageFooterName
{
get
{
return
pageFooterName;
}
set
{
pageFooterName =
value;
}
}
//是否打印页数
public bool
IsPrintPage
{
get
{
return
isPrintPage;
}
set
{
isPrintPage =
value;
}
}
//是否打印时间
public bool
IsPrintDate
{
get
{
return
isPrintDate;
}
set
{
isPrintDate =
value;
}
}
//header的位置(左,中,右)
public int
HeaderLocation
{
get
{
return
headerLocation;
}
set
{
headerLocation=value;
}
}
//footer的位置(左,中,右)
public int
FooterLocation
{
get
{
return
footerLocation;
}
set
{
footerLocation=value;
}
}
//页数的位置
public int
PageLocation
{
get
{
return
pageLocation;
}
set
{
pageLocation=value;
}
}
//时间的位置
public int
DateLocation
{
get
{
return
dateLocation;
}
set
{
dateLocation=value;
}
}
//是否允许编辑页面
public bool
EnableEditPage
{
get
{
return
enableEditPage;
}
set
{
enableEditPage =
value;
}
}
//标题字体
public
System.Drawing.Font PageHeaderFont
{
get
{
return
pageHeaderFont;
}
set
{
pageHeaderFont =
value;
}
}
//页脚字体
public
System.Drawing.Font PageFooterFont
{
get
{
return
pageFooterFont;
}
set
{
pageFooterFont =
value;
}
}
//页边距
public
System.Drawing.Printing.Margins DevMargins
{
get
{
return
devMargins;
}
set
{
devMargins =
value;
}
}
//纸张类型
public
System.Drawing.Printing.PaperKind DevPaperKind
{
get
{
return
devPaperKind;
}
set
{
devPaperKind =
value;
}
}
//*********************字段*********************
private
void PageHeaderFooterSettings
()
{
PHA.Content.Clear();
PFA.Content.Clear();
string[] stringsPHA = new string[]
{'','',''};
string[] stringsPFA = new string[]
{'','',''};
switch(headerLocation)
{
case
0:stringsPHA[0]=pageHeaderName;
break;
case
1:stringsPHA[1]=pageHeaderName;
break;
case
2:stringsPHA[2]=pageHeaderName;
break;
default:stringsPHA[1]=pageHeaderName;
break;
};
switch(footerLocation)
{
case
0:stringsPFA[0]=pageFooterName;
break;
case
1:stringsPFA[1]=pageFooterName;
break;
case
2:stringsPFA[2]=pageFooterName;
break;
default:stringsPFA[1]=pageFooterName;
break;
};
if (isPrintPage)
{
switch(pageLocation)
{
case
0:stringsPHA[0]=stringsPHA[0]+'[Page # of Pages #]';
break;
case
1:stringsPHA[1]=stringsPHA[1]+'[Page # of Pages #]';
break;
case
2:stringsPHA[2]=stringsPHA[2]+'[Page # of Pages #]';
break;
case
3:stringsPFA[2]=stringsPFA[2]+'[Page # of Pages #]';
break;
case
4:stringsPFA[1]=stringsPFA[1]+'[Page # of Pages #]';
break;
case
5:stringsPFA[0]=stringsPFA[0]+'[Page # of Pages #]';
break;
default:stringsPFA[2]=stringsPFA[2]+'[Page # of Pages #]';
break;
};
}
if (isPrintDate)
{
switch(dateLocation)
{
case
0:stringsPHA[0]=stringsPHA[0]+'[Date Printed]';
break;
case
1:stringsPHA[1]=stringsPHA[1]+'[Date Printed]';
break;
case
2:stringsPHA[2]=stringsPHA[0]+'[Date Printed]';
break;
case
3:stringsPFA[2]=stringsPFA[2]+'[Date Printed]';
break;
case
4:stringsPFA[1]=stringsPFA[1]+'[Date Printed]';
break;
case
5:stringsPFA[0]=stringsPFA[0]+'[Date Printed]';
break;
default:stringsPFA[0]=stringsPFA[0]+'[Date Printed]';
break;
};
}
PHA.Content.AddRange(stringsPHA);
PFA.Content.AddRange(stringsPFA);
if (pageHeaderFont != null)
{
try
{
PHA.Font = pageHeaderFont;
}
catch
{
PHA.Font = new Font(new
System.Drawing.FontFamily('楷体_GB2312'),20,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point);
}
}
else
{
PHA.Font =
new Font(new
System.Drawing.FontFamily('楷体_GB2312'),20,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point);
}
if (pageFooterFont != null)
{
try
{
PFA.Font = pageFooterFont;
}
catch
{
PFA.Font = new Font(new
System.Drawing.FontFamily('楷体_GB2312'),9,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point);
}
}
}
public void
ShowDevPreview(DevExpress.XtraPrinting.IPrintable
printComponent)
{
PageHeaderFooterSettings
();
DevExpress.XtraPrinting.PrintingSystem ps =
new DevExpress.XtraPrinting.PrintingSystem();
DevExpress.XtraPrinting.PrintableComponentLink pc =new
DevExpress.XtraPrinting.PrintableComponentLink();
pc.Component = printComponent;
pc.Landscape = true;
//是否指定页边距尺寸
if (devMargins != null)
pc.Margins
= devMargins;
//是否定义纸张
if (devPaperKind !=
System.Drawing.Printing.PaperKind.A4)
pc.PaperKind =
devPaperKind;
//标题和页脚的显示
pc.PageHeaderFooter =
new
DevExpress.XtraPrinting.PageHeaderFooter(PHA,PFA);
pc.CreateDocument(ps);
pc.EnablePageDialog = enableEditPage;
pc.ShowPreview();
}
}