TileView 基本配置
...
图片缩放设置
/// <summary> /// TileViewColumn 相关属性设置 /// </summary> /// <param name="tvcID">TileViewColumn对象</param> /// <param name="Name">Name属性</param> /// <param name="Caption">标题</param> /// <param name="FieldName">数据源字段</param> /// <param name="ShowCaption">bool值,是否展示Caption:选卡展示列的内容时是否展示标题(Caption)</param> /// <param name="Visible">bool值,是否显示</param> /// <param name="VisibleIndex">int ,排序位置:默认0开始</param> public void SetTileViewColumn(DevExpress.XtraGrid.Columns.TileViewColumn tvcID,string Name,string Caption,string FieldName,bool ShowCaption,bool Visible,int VisibleIndex) { tvcID.Caption = Caption;/* 标题 */ tvcID.FieldName = FieldName;/* 数据源字段 */ tvcID.Name = Name;/* Name属性 */ tvcID.OptionsColumn.ShowCaption = ShowCaption;/* 是否展示Caption:选卡展示列的内容时是否展示标题(Caption) */ tvcID.Visible = Visible;/* 是否显示列 */ tvcID.VisibleIndex = VisibleIndex;/* 排序位置:默认0开始 */ tvcID.ColumnEdit = new DevExpress.XtraEditors.Repository.RepositoryItem(); } public void TitleViewSet( TileView tileView) { /* 配置gridControl1.RepositoryItems,TileView调用时,直接给TileViewColumn.ColumnEdit赋值 */ DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit rpIPictureEdit = new DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit(); ((System.ComponentModel.ISupportInitialize)(rpIPictureEdit)).BeginInit(); rpIPictureEdit.CustomHeight = 200; rpIPictureEdit.Name = "rpIPictureEdit"; /* 添加单个内部控件*/ this.gridControl1.RepositoryItems.Add(repositoryItemPictureEdit1 ); /*添加多个内部控件*/ this.gridControl1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { rpIPictureEdit, this.repositoryItemTextEdit1, this.repositoryItemTextEdit2, this.repositoryItemPictureEdit2}); ((System.ComponentModel.ISupportInitialize)(rpIPictureEdit)).EndInit(); /* 绑定数据源列:直接绑定数据源;*/ DevExpress.XtraGrid.Columns.TileViewColumn tvcID = new DevExpress.XtraGrid.Columns.TileViewColumn(); /* 行列对象 */ DevExpress.XtraEditors.TableLayout.TableColumnDefinition tableColumnDefinition1 = new DevExpress.XtraEditors.TableLayout.TableColumnDefinition(); DevExpress.XtraEditors.TableLayout.TableRowDefinition tableRowDefinition1 = new DevExpress.XtraEditors.TableLayout.TableRowDefinition(); /* 页面布局列:可关联TileViewColumn,也可自定义; */ DevExpress.XtraGrid.Views.Tile.TileViewItemElement tVIElementID = new DevExpress.XtraGrid.Views.Tile.TileViewItemElement(); DevExpress.XtraGrid.Views.Tile.TileViewItemElement tVIElement = new DevExpress.XtraGrid.Views.Tile.TileViewItemElement(); tVIElement.Column = tvcName;/* 配置TileViewItemElement对应的TileViewColumn对象*/ tVIElement.AnchorAlignment = DevExpress.Utils.AnchorAlignment.Left; /* 锚定 :Top , Left , Right , Bottom ,设置锚定方式 */ tVIElement.AnchorElement = tVIElementID; /* 锚定元素:按 某个元素或者控件进行锚定,锚定方式按AnchorAlignment 设置 */ tVIElement.AnchorIndent = 100;/* 参照对象(AnchorElement配置参照对象),排列方式(AnchorAlignment上下左右),设置相对距离;*/ tVIElement.AnchorOffset = new System.Drawing.Point(10, 10);/* 相对坐标配置:在AnchorElement、AnchorIndent的配置基础上配置X、Y坐标*/ tVIElement.AnchorElementIndex = 0; tVIElement.ImageOptions.ImageAlignment = DevExpress.XtraEditors.TileItemContentAlignment.MiddleCenter; tVIElement.ImageOptions.ImageScaleMode = DevExpress.XtraEditors.TileItemImageScaleMode.ZoomInside; tVIElement.Text = "tvcName"; tVIElement.TextAlignment = DevExpress.XtraEditors.TileItemContentAlignment.MiddleCenter; tileView.TileTemplate.Add(tVIElement); /* 添加列 */ tileView.Columns.AddRange ( new DevExpress.XtraGrid.Columns.GridColumn[] { tvcID, tvcPhoto, tvcPhotoName, tvcName } ); tileView.ColumnSet.CheckedColumn = tvcID; /*勾选状态,指定的列的值为: 1(选卡勾选状态),0 或者其他(选卡未勾选状态)*/ tileView.ColumnSet.EnabledColumn = tvcID;/*TileView卡片的Enabled权限,指定列的值为:0(卡片灰色不能选中),0(卡片可选中);*/ tileView.ColumnSet.GroupColumn = tvcID; /*TileView卡片分组:指定的列的值如果相同,归为同组;*/ tileView.GridControl = gridControl1;/* */ tileView.Name = "tileView1";/* */ tileView.OptionsTiles.ItemPadding = new System.Windows.Forms.Padding(0);/* Padding值设置 */ tileView.OptionsTiles.ItemSize = new System.Drawing.Size(360, 180);/* 卡片Size尺寸设置 */ tileView.OptionsTiles.Orientation = System.Windows.Forms.Orientation.Horizontal;/* 滚动方向设置;Horizontal水平滚动(默认),Vertical垂直滚动 */ tileView.OptionsTiles.ColumnCount = 3;/* 当Orientation = Vertical垂直滚动时,横排最多3个选卡,此时RowCount设置无效 */ tileView.OptionsTiles.RowCount = 2;/* 当Orientation = Horizontal水平滚动,竖排最多2个选卡,此时ColumnCount设置无效 */ tileView.DetailHeight = 100;/* */ /* 排序列 */ tileView.SortInfo.AddRange ( new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] { new DevExpress.XtraGrid.Columns.GridColumnSortInfo(tvcID, DevExpress.Data.ColumnSortOrder.Ascending)/*TileViewColumn , 排序方式*/ } ); tileView.TileColumns.Add(tableColumnDefinition1); tileView.TileRows.Add(tableRowDefinition1); }
....