admin 管理员组文章数量: 1086019
2023年12月18日发(作者:distinguish的用法)
第三方控件使用大全
【张杰章开发过程中整理】
一、ComboBoxEdit
1、 如何使其不可编辑
TextEditStyle 设置为:DisableTextEditor
2、 如何设置鼠标为手形
Cursor 设置为:Hand
二、GridControl
1、 如何解决单击记录整行选中的问题
View->OptionsBehavior->EditorShowMode 设置为:Click
2、 如何新增一条记录
(1)、Row()
(2)、实现gridView_InitNewRow事件
3、如何解决GridControl记录能获取而没有显示出来的问题
teColumns();
4、如何让行只能选择而不能编辑(或编辑某一单元格)
(1)、View->OptionsBehavior->EditorShowMode 设置为:Click
(2)、View->OptionsBehavior->Editable 设置为:false
5、如何禁用GridControl中单击列弹出右键菜单
设置Run Design->OptionsMenu->EnableColumnMenu 设置为:false
6、如何隐藏GridControl的GroupPanel表头
设置Run Design->OptionsView->ShowGroupPanel 设置为:false
7、如何禁用GridControl中列头的过滤器
过滤器如下图所示:
设置 Run Design->OptionsCustomization->AllowFilter 设置为:false
8、如何在查询得到0条记录时显示自定义的字符提示/显示
如图所示:
方法如下:
//When no Records Are Being Displayed
private void gridView1_CustomDrawEmptyForeground(object sender,
CustomDrawEventArgs e)
{
//方法一(此方法为GridView设置了数据源绑定时,可用)
ColumnView columnView = sender as ColumnView;
BindingSource bindingSource = urce as
BindingSource;
if( == 0)
{
string str = "没有查询到你所想要的数据!";
Font f = new Font("宋体", 10, );
Rectangle r = new Rectangle( + 5, + 5,
- 5, - 5);
ring(str, f, , r);
}
//方法二(此方法为GridView没有设置数据源绑定时,使用,一般使用此种方法)
if (this._flag)
{
if (nt == 0)
{
string str = "没有查询到你所想要的数据!";
Font f = new Font("宋体", 10, );
Rectangle r = new Rectangle( + 5, +
5, - 5, - 5);
ring(str, f, , r);
}
}
}
9、如何显示水平滚动条?
设置AutoWidth = false;
10、如何定位到第一条数据/记录?
设置 rst()
11、如何定位到下一条数据/记录?
设置 xt()
12、如何定位到最后一条数据/记录?
设置 st()
13、设置成一次选择一行,并且不能被编辑
ectStyle =
us;
le = false;
AppearanceFocusedCell = false;
14、如何显示行号?
torWidth = 40;
//显示行的序号
private void gridView1_CustomDrawRowIndicator(object sender,
RowIndicatorCustomDrawEventArgs e)
{
if (ndicator && dle>=0)
{
yText = (dle + 1).ToString();
}
}
15、如何让各列头禁止移动?
设置olumnMoving = false;
16、如何让各列头禁止排序?
设置ort = false;
17、如何禁止各列头改变列宽?
设置olumnResizing = false;
18、
19、
20、
21、
22、
23、
24、
25、
26、
三、navBarControl
1、如何在每一个navBarGroup里添加自己想要的控件
设置GroupStyle: ControlContainer
2、如何设置navBarGroup有滚动条
设置SkinExplorerBarViewScrollStyle:ScrollBar
3、 如休把navBarGroup设置成如下样式
如图所示:
设置navBarGroup的PaintStyleName属性为: SkinNavigationPane
四、toolTipController
效果图如下:
1、如何设置显示的时间长短
设置pDelay = 2000;
2、如何在屏幕上显示如上图所示的效果
ToolTipControllerShowEventArgs args =
ShowArgs();
lTip(s, "请选择一条记录!");
le(s, "提示");
lTipIconType(s,
ation);
ak = true;
adow = true;
d = true;
nt("请选择一条记录!", "提示");
p = "请选择一条记录!";
= "提示";
3、如何设置边框的颜色
Color = ;
五、TextEdit
1、如何设置TextEdit为多行,可拉伸
设置TextEdit的Propertity->AutoHeight为:False
六、LayoutControl
1、如何设置LayoutItem为隐藏
设置lity = Never
七、TreeList
1、如何隐藏TreeList的列头
设置TreeListr的OptionsView的ShowColumns属性为:False
2、如何
八、PictureEdit
1、如何禁止PictureEdit的右键菜单?
设置PictureEdit的Properties->ShowMenu为:false
九、TreeList
1、 如何让TreeList的每个结点高亮显示?
效果如下:
代码如下:
private void treeList1_CustomDrawNodeCell(object sender,
DrawNodeCellEventArgs e)
{
TreeList node = sender as TreeList;
if ( == dNode)
{
ctangle(, );
Rectangle r = new Rectangle(,
,
).Width + 1),
32(eString(xt,).Height));
ctangle(ght, r);
ring(xt, , ghtText, r);
d = true;
}
}
32(eString(xt,
//============================================================================
//===============================以下内容为收集===============================
//============================================================================
一、改变grid的样式。
rances xapp;
xapp=new
rances(derPath() + " ");
heme(“样式名字”, ew);
二、选择单元设置和取所选的值
electMode= lect;
electMode= GridMultiSelectMode. RowSelect; //
elect = d; //多行选择
三、gridview的控制
///<取当前选中的值>
string GetSelectedRows(GridView view) {
string ret = "";
int rowIndex = -1;
if(electMode == ect) {
foreach(int i in ectedRows()) {
DataRow row = aRow(i);
if(ret != "") ret += "rn";
ret += ("Company Name: {0} (#{1})", row["CompanyName"], i);
}
}
else {
foreach(GridCell cell in ectedCells()) {
if(rowIndex != dle) {
if(ret != "") ret += "rn";
ret += ("Row: #{0}", dle);
}
ret += "rn " + CellDisplayText(dle,
);
rowIndex = dle;
}
}
return ret;
}
///<设置选中的颜色>//半透明的效果
private void icbTranslucentColors_CheckedChanged(object sender, rgs e) {
if(d) {
lor = gb(30, 0, 0, 240);
lor = gb(60, 0, 0, 240);
}
else {
();
();
}
}
///<自动添加一行>
mRowPosition = //Top/None;
///<设置gridView的按钮>
ttonMode = ShowButtonModeEnum.。。。。。。
le = d; //设置按钮是否可用
///向选中的空间输入字符串
(“fsfds”);
///控件焦点
();
四、cardView的设置
///是否现实快捷按钮CustomizeButton
ickCustomizeButton=true/false;
///设置CustomizeButton的能否排序和过滤
foreach(GridColumn col in s)
{ ort}
foreach(GridColumn col in s)
{ ilter}
///card的头上的ico显示
Changed();
///card的头上的标题改变显示
ptionFormat =””;
///cardview显示的单个记录的折叠按钮
rdExpandButton=true;
///
mCardColumns =iSize
mCardRows = val;
rzWidth
///多选
elect = d;
foreach(int i in ectedRows()) {
DataRow row = aRow(i);
if(ret != "") ret += "rn";
ret += ("{0} / {1} : {2:$#,0.00}", row["Trademark"], row["Model"],
row["Price"]);
}///查看选择中的记录
CellMerging(单元格合并的效果)
///
CellMerging(单元格合并的效果)
ellMerge = d;
Fixed Bands(bandedGridView)
///两边固定
gridBand3 的一列的Fixed属性改成 Right,Left,None
///固定与非固定列之间的距离用
ineWidth = (int);
///设置列的颜色
打开Run Designer 选中Columns 选中要改变的列 里面有AppearanceCell (设置列的外观)和
AppearanceHeader(设置表格头的外观)
或者选中该列查看“属性”里面也有这两个属性。
///统计 (gridView bandedGridView通用)
分组统计和全部统计:
全部统计:在最下面显示统计的结果。
Run Designer->Total Summary //->General 设置显示
//->Columns 对特定列来设置统计
汇总结果是否显示:可以通过gridControl的view的ShowFooter属性来设置表格下面的汇总结果
分组统计:
以上就是“分组”的 显示在每个分组下面来显示汇总结果。
通过ooterShowMode= GroupFooterShowMode.。。。。设置分组的显示模式。
///GridView设置菜单
#region Grid events
private
void gridView1_ShowGridMenu(object sender,
nuEventArgs e) {
if(pe == ) {
ewColumnMenu menu = as
ewColumnMenu;
();
if( != null) {
(CreateCheckItem("Not Fixed", ,
, [0]));
(CreateCheckItem("Fixed
(CreateCheckItem("Fixed
Left",
Right",
,
,
, [1]));
, [2]));
}
#endregion
#region New column menu
DXMenuCheckItem CreateCheckItem(string caption, GridColumn column, FixedStyle style,
}
}
Image image) {
}
void OnFixedClick(object sender, EventArgs e) {
}
class MenuInfo {
}
public MenuInfo(GridColumn column, FixedStyle style) {
}
public FixedStyle Style;
public GridColumn Column;
= column;
= style;
DXMenuItem item = sender as DXMenuItem;
MenuInfo info = as MenuInfo;
if(info == null) return;
= ;
DXMenuCheckItem item = new DXMenuCheckItem(caption, == style, image,
= new MenuInfo(column, style);
return item;
new EventHandler(OnFixedClick));
#endregion
///gridview cardView自动行高
行高自动匹配
oHeight = d;
utoHeight = d;
当文字多的时候(行高自动匹配 设置是才有用)
ount = d ? 0 : 1;
设置自动全部显示该的所有行。
///BandedGridView自己订制列的方法
sCustomization();
yCustomization();
hangeColumnParent = d;
hangeBandParent = d;
ndsInCustomizationForm = d;
///设置 图片动画模式
ionType = (GridAnimationType)
///根据字段来分组模式
switch(index) {
case 0:
SetInterval(gridColumn1, etical);
nterval = etical;
break;
SetInterval(gridColumn5, nth);
break;
图片时(行高自动匹配 设置是才有用)
Height = d ? 0 : 40;
case 1:
case 2:
SetInterval(gridColumn5, ar);
break;
SetInterval(gridColumn5, nge);
break;
case 3:
case 4:
SetSortMode(gridColumn4, );
break;
default:
SetInterval(gridColumn2, );
break;
}
void SetInterval(GridColumn column, ColumnGroupInterval interval) {
}
void SetSortMode(GridColumn column, ColumnSortMode sortMode) {
}
de = sortMode;
ndex = 0;
nterval = interval;
ndex = 0;
改变分组样式
rawMode = (GroupDrawMode)
///清除分组
rouping();
foreach(GridColumn column in s) {
nterval = t;
de = t;
}
///CustomDataSummaries设置Grop
private void numCustom_ValueChanged(object sender, rgs e) {
Summary();
UpdateCaptions();
}
private void UpdateCaptions(decimal d) {
ummary[0].DisplayFormat = "(Order Count [WHERE Freight >= " +
ng() + "] = {0})";
OnSetCaption("");
Conditions[0].Value1 = d;
}
protected override void OnSetCaption(string fCaption) {
fCaption = "count records WHERE Freight >= " + ng();
if(Caption != null)
= ("{0} ({1})", TutorialName, fCaption);
}
///下面的效果的实现
Run Designere -> Style Conditions ->Add ->column设置列的 Condition设置条件 value1,value2是参数值
代码:
public void setStyle(GridView gridView)
{
StyleFormatCondition cn;
cn = new StyleFormatCondition(, s["bd_c"],
null,false);
oRow = true;//false只对列其作用。
= new Font(tFont, );
lor = ;
(cn);
}
///LayoutView
ngle = (float)(((int)lue) / 360.0f * 2
* );///卡片的高度设置lue的值(0-360)
gle = (float)(((int)lue) / 360.0f * 2 *
);// ///卡片的旋转角度设置lue的值(0-360)
CardScale = ((int)lue) / 100.0f;
///卡片的距离设置lue的值(0-100)
CardAlphaLevel = ((int)lue) / 100.0f;
///卡片的卡片透明程度设置lue的值(0-100)
CardFading = ((int)lue) /
100.0f; ///卡片的卡片褪色程度设置lue的值(0-100)
unt = (int)lue;
///卡片的能显示数量设置lue的值(0-20)
olationMode = (InterpolationMode)
//修改卡片的方式
///layout卡片的样式在 run designer -> layout里面设置
Size originalCardMinSize = ;
private void zoomTrackBarControl1_EditValueChanged(object sender, EventArgs e) {
if(originalCardMinSize == ) originalCardMinSize =
nSize;
double koeff = ((int)lue) / 100.0 - 0.2;
Size newSize = new Size( + (int)(
* koeff), + (int)( * koeff));
nSize = newSize;
}////设置卡片的大小的(zoomTrackBarControl1z(0-100))
下图中设置layoutView位置的方法
protected void SetMasterTableLeftPlacement() {
LayoutItemDragController dc = new LayoutItemDragController(masterTableItem,
detailTableItem, , ntal);
DoDragItem(dc);
SetMasterViewColumnLayout();
}
protected void SetMasterTableRightPlacement() {
LayoutItemDragController dc = new LayoutItemDragController(masterTableItem,
detailTableItem, , ntal);
DoDragItem(dc);
SetMasterViewColumnLayout();
}
private void SetMasterTableTopPlacement() {
LayoutItemDragController dc = new LayoutItemDragController(masterTableItem,
detailTableItem, , al);
DoDragItem(dc);
SetMasterViewRowLayout();
}
protected void SetMasterTableBottomPlacement() {
LayoutItemDragController dc = new LayoutItemDragController(masterTableItem,
detailTableItem, , al);
DoDragItem(dc);
SetMasterViewRowLayout();
}
protected void DoDragItem(LayoutItemDragController dc) {
nstraintsType =
t;
(dc);
}
protected void SetMasterViewColumnLayout() {
SetMasterItemVerticalSize();
witchViewModes = true;
de = ;
witchViewModes = false;
h();
}
protected void SetMasterViewRowLayout() {
SetMasterItemHorizontalSize();
witchViewModes = true;
de = ;
witchViewModes = false;
h();
}//// private ControlItem masterTableItem;
///直接打印gridcontrol
Cursor currentCursor = t;
t = rsor; //取当前的鼠标。并设置
if(tingAvailable)
eview(gridControl1);///打印
else
("XtraPrinting Library is ", "Information", ,
ation);
t = currentCursor;
版权声明:本文标题:第三方控件(DevExpress)使用大全【个人开发过程中整理收集】_ 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1702860381a433595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论