UltraGrid 的常用功能
Databinding和DataGrid一样,设定DataSource就可以了。
比较方便的做法是把Ultragrid 拖动到Designer上,然后通过PropertyGrid来调整。
(1)不同值可以给以不同的颜色。
Properties-> DisplayLayout->bands->0-XXX->Columns->从弹出窗口中,选择一个列->ValueBaseAppearance->添加Conditions,即可。
(2)给每一行一个说明
在InitializeRow的Event响应中,写e.row.Description="My description"即可。事先需要设定,this.ultraGrid1.DisplayLayout.Bands[0].AutoPreviewEnabled = true;
(3)某一行采用渐变色
UltraGridRow objRow = this.ultraGrid1.Rows[10] ;
this.ultraGrid1.ActiveRow = objRow;
this.ultraGrid1.Rows[10].Appearance.BackColor2 = Color.Blue;
this.ultraGrid1.Rows[10].Appearance.BackGradientStyle = GradientStyle.Circular;
(4)在Runtime改变格式设置
this.ultraGrid1.ApplyPresetFromXml(文件名,true)
(5)设定每一列的宽度
foreach ( UltraGridColumn column in e.Layout.Bands[0].Columns )
{
column.Width = 100;
}
(6) 生成使用Appearance
this.ultraGrid1.DisplayLayout.Appearances.Add("Highlighted" );
this.ultraGrid1.DisplayLayout.Appearances["Highlighted" ].BackColor = Color.Red;
this.ultraGrid1.DisplayLayout.Appearances["Highlighted" ].BackColor = Color.White;
或者直接给预设Appearance赋值
this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.ForeColor = Color.White;
(7)使用Dropdown List
在Properties-> DisplayLayout->ValueLists,添加ValueList
Properties-> DisplayLayout->bands->0-XXX->Columns->某个Column->ValueList等于新添加的ValueList,同时设定Style是DropDown
grid中header置顶不动
设置displaylayout中的stationarymargins
grid中设置数据筛选
// The Browser, LoadOnDemand, and ViewType settings to enable XmlHttp support were done at design time. // Many of these setting can be done at design time but are done here to show them being set explictly.
// Turn on Filtering
Layout.FilterOptionsDefault.AllowRowFiltering = Infragistics.WebUI.UltraWebGrid.RowFiltering.OnServer;
// Limit the size of the dropdown
Layout.FilterOptionsDefault.DropDownRowCount = 10;
Layout.FilterOptionsDefault.FilterDropDownStyle.Width = Unit.Pixel(190)
// Turn on RowIsland Filtering
// RowIsland filtering only filters the siblings rows of a group. For Band Zero, all Band Zero rows are siblings so there
// is little difference in the modes, however in child bands, this behavior is more evident.
Layout.FilterOptionsDefault.RowFilterMode = Infragistics.WebUI.UltraWebGrid.RowFilterMode.SiblingRowsOnly;
在grid的FilterPopulating中
// Get the unique country names
e.WorkingList.AddRange( ArrayList );
// Tell the WebGrid not to go looking for the data. By setting this
// flag to true, the WebGrid uses the provided list for it's data.
e.Handled = true;
grid的数据源需要在InitializeDataSource中设置
grid需要绑定在一个固定的datatable中,不可动态new的
每一个row需要设定为isbound = true
grid使用ajax自动读取数据
设置browser 未xml , LoadOnDemand为 xml ,并设置ViewType为Hierarchical即可,但是需要在InitializeDataSource中绑定数据
grid中获得置顶的column
Layout.Bands[0].Columns.FromKey("Key")
grid中分页
设置Pager中允许分页,分页大小
在InitializeDataSource绑定数据
自定义分页需要设置
Layout.Pager.StyleMode = Infragistics.WebUI.UltraWebGrid.PagerStyleMode.CustomLabels;
pattern设置为:<table width=100%><tr><td align=left>页码:[currentpageindex]/[pagecount] 每页:[pagesize]</td><td align=right>[default]<td></tr></table>
Layout.Pager.CustomLabels = letters;
Page中AllowCustomPaging并在PageIndexChanged设定要显示的数据
比如 设定数据源为customerTable2在PageIndexChanged中设定:
customerTable2.DefaultView.RowFilter = "CustomerID LIKE '" + letters[e.NewPageIndex-1] + "%'";
letters为:
letters = new string[letterCount];
for (int i = 0 ; i < letterCount ; i++)
letters[i] = ((char)((int)'A'+i)).ToString();
Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter 和控件Infragistics.Win.UltraWinGrid.UltraGrid
及控件System.Windows.Forms.SaveFileDialog
连用实现数据导入Excel表格的用法
当UltraGrid已经绑定有数据后
dim strFilePath as String
with SaveFileDialog
.Filter="Excel(*.xls)|*.xls"
.RestoreDirectory=True
strFilePath=.FileName
if .ShowDialog = DialogResult.OK Then
UltraGridExcelExporter.Export(UltraGrid,strFilePath)
end if
end with
Corgent.Diagramming.WinFormsControl.DiagramWinFormsControl中控件DiagramWinFormsControl常用的属性
DiagramWinFormControl.PageAlignment(页的排列方式)
DiagramWinFormControl.ShowGrid=True/False 是否显示网格线
DiagramWinFormControl.ShowGuides=True/False 是显示指南导航
DiagramWinFormControl.ShowPageNavigator=True/False 是否显示页导航
DiagramWinFormControl.ShowRulers=True/False 是否显示标尺
DiagramWinFormControl.ShowZoomTracker=True/False 是否显示缩放导航
DiagramWinFormControl.ZoomToFit=True/False 是否自动缩放到合适比例
System.Windows.Forms.ListView中控件ListView常用到的属性
ListView.View=Details 以详细信息的方式显示
ListView.FullRowSelect=True/False 是否可以选中整行
ListView.GridLines=True/False 是否显示网格线
ListView.Columns.Add(列名称,列宽度,对齐方式) 增加列头
ListView.SelectedItems.Count 被选中的行数
ListView.Items(index).SubItems.Add 向某一行某一列(项)增加信息
DevExpress.XtraGrid.GridControl控件涉及到重绑定时,若是绑定数据结构不同的表,应先清空该控件默认的视图
GridControl.DataSource=nothing
GridView1.Columns.Clear
DevExpress.XtraNavBar.NavBarGroup中控件NavBarGroup常用到的属性
NavBarGroup.GroupStyle=ControlContainer 可以在该控件中再增加别的控件