UltraWinGrid使用TIPS(转载)

UltraWinGrid行号从0开始

 

CellMultiLine

Cell多行显示

当设定一个Column的CellMultiLine为True时,如果想要格子自动增长(变大),必须设定RowSizing的属性为AutoFree或Free

ultraGridColumn31.CellMultiLine =Infragistics.Win.DefaultableBoolean.True;

ultraGridBand1.Override.RowSizing =Infragistics.Win.UltraWinGrid.RowSizing.AutoFree;

 

Rowsizing

行变化

ColumnSizing

列变化

 

MultiCellSelectionMode

 

多个Cell的选择

 

SummaryFooterCaption

汇总标题

汇总的标题,默认为Grand Summaries,可以运行中根据汇总的字段进行更改

 

MergedCell

合并相似Cell

ultraGridColumn8.MergedCellEvaluationType =       

                            Infragistics.Win.UltraWinGrid.MergedCellEvaluationType.MergeSameText;

ultraGridColumn8.MergedCellStyle =Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;

 

SummaryDisplayAreas

汇总显示区域

显示汇总信息的位置,默认显示在Group项的标题行

ugSchedule.DisplayLayout.Override.SummaryDisplayArea =SummaryDisplayAreas.Bottom;

 

HeaderVisible

Band项的Header

 ugSchedule.DisplayLayout.Bands[1].HeaderVisible= true;

ugSchedule.DisplayLayout.Bands[1].Header.Caption = "asfafa";

 

//ugSchedule.DisplayLayout.Override.SummaryDisplayArea =SummaryDisplayAreas.Bottom;

//ugSchedule.DisplayLayout.Bands[1].Header.Appearance.BackColor =Color.LightBlue;

//ugSchedule.DisplayLayout.Bands[1].Header.Appearance.BackColor2  = Color.LightBlue;

 

ColHeaderVisible

不显示Bands的表头

ugSchedule.DisplayLayout.Bands[1].ColHeadersVisible = false;

 

Columns标题颜色

 

ugSchedule.DisplayLayout.Bands[1].Columns[0].Header.Appearance.BackColor= Color.LightCoral;

 

ColumnStyle

Column样式(下拉框)

 

UltraDropDown KindList = new UltraDropDown();//建立一个下拉对象

KindList.DataSource = cboLine.DataSource;//绑定数据源

 

e.Layout.Bands["OrderHeader"].Columns["Kind"].ValueList= KindList;//绑定到Column

 

ActiveRow

当前行和选中内容

ugSchedule.Selected.Rows[0].Cells[0].Value.ToString()ugSchedule.Rows[ugSchedule.ActiveRow.Index].Cells[0].Value.ToString()

ugSchedule.Rows[SignRow].Activate();

Band.Index

判断当前行是子行还是父行

MessageBox.Show(ugSchedule.ActiveRow.Band.Index.ToString());

 

Expand

展开或关闭关联

In C#:

// Expands the current row andits children as well
this.UltraWebGrid1.Rows[0].Expand(true); //展开单个行

this.UltraWebGrid1.ExpandAll(true);

ugOrder.ActiveRow.Expanded = true;

 

UltraGridBand

定义绑定,实现遍历子行

int BandRow = 0;                 

UltraGridBand band=ugSchedule.DisplayLayout.Bands["Schedule"];

               

foreach (UltraGridRow row inband.GetRowEnumerator(GridRowType.DataRow))

{

BandRow++;

MessageBox.Show(row.Cells[2].Value.ToString()); 

}

MessageBox.Show (BandRow.ToString());

 

 ////ugSchedule.DisplayLayout.Bands[1].AddNew();  

            int BandRow = 0;

            UltraGridBand band =ugSchedule.DisplayLayout.Bands["Sign"];

 

            foreach (UltraGridRowrow in band.GetRowEnumerator(GridRowType.DataRow))

            {

                BandRow++;

               row.Cells["SignMemo"].Activate();

                row.Cells["SignMemo"].Value =row.Index.ToString();

            }

 

           MessageBox.Show(BandRow.ToString());

 

 

AllowMultiCellOperations

回复操作

*

// Turn on all of the Cut, Copy,and Paste functionality.

e.Layout.Override.AllowMultiCellOperations= AllowMultiCellOperation.All;

 

Member

Description

Default

Default is resolved to None.

None

No multi cell operations are allowed.

Copy

Allows copying of multiple cells to the clipboard.

CopyWithHeaders

Same as Copy except that an extra row of column headers will be copied as well.

Cut

Allows cutting of multiple cells to the clipboard. Cutting involves first copying of the cell values to the clipboard and then clearing the contents of the copied cells.

Delete

Allows clearing contents of multiple cells. Cell contents are set to associated columnsUltraGridColumn.DefaultCellValue property settings, which by default isDBNull.

Paste

Allows pasting of multiple cells from the clipboard.

Undo

Allows Undo operation. Last multi cell operation will be undone.

Redo

Allows Redo operation.

Reserved

Reserved. For internal use only.

All

Allows all of operations listed in this enum.

 

CellClickAction

CELL单击的时候产生的效果

 

Member

Description

Default

Use Default. The setting of the object‘s parent will be used (Edit if parent has no default.)

Edit

Edit. Selects and highlights the cell that was clicked and puts it in edit mode.

RowSelect

Row Select. Selects and highlights the entire row of the cell that was clicked. Note that if a cell is displaying a drop down button the clicking onto it will cause the cell to go into edit mode. To prevent the cell from going into edit mode seeUltraGridColumn.CellActivation. To prevent the drop down buttons from showing, set theUltraGridColumn.ButtonDisplayStyle property.

CellSelect

Cell Select. Selects and highlights the cell that was clicked. Note that if a cell is displaying a drop down button the clicking onto it will cause the cell to go into edit mode. To prevent the cell from going into edit mode seeUltraGridColumn.CellActivation. To prevent the drop down buttons from showing, set theUltraGridColumn.ButtonDisplayStyle property.

EditAndSelectText

Edit and Select Text. Puts the cell into edit mode and selects its text, if any.

 

标题换行

标题手动换行

 

ugSchedule.DisplayLayout.Bands[0].Columns[0].Header.Caption = "第一行"+"\n"+"第二行";

DisplayLayout.Override.WrapHeaderText

 

更改Cell的背景颜色

 

//e.Cell.Appearance.BackColor = Color.LightGreen;

//e.Cell.Appearance.BackColor2 = Color.LightGreen;

 

判断是否有子,父行,显示父行的Index

 

ugSchedule.Rows[0].HasChild(true)

ugSchedule.Rows[0].HasParent(true)         

MessageBox.Show(ugSchedule.Selected.Rows[0].ParentRow.Index.ToString());

 

列表包含

Exists

if ( this.ultraGrid1.DisplayLayout.ValueLists.Exists( "VL1" ) )

               return;

 

 

ValueList

增加ValueList

 

private void InitializeValueLists()

{

Infragistics.Win.ValueListsCollection lists =this.UltraGrid1.DisplayLayout.ValueLists;

Infragistics.Win.ValueList vl =lists.Add("DropDownValidate");

for (int i = 0; i < 100; i++)

vl.ValueListItems.Add(i,i.ToString());

vl = lists.Add("Presidents");

for (int i = 0; i < arrNames.GetLength(0); i++)

vl.ValueListItems.Add(i,arrNames[i]);

}

 

SortedColumns

手动增加排序并分组

public int Add( 
   UltraGridColumn column,
   bool descending,
   bool groupBy
)

Parameters

column

The column to add to the collection.

descending

True to sort the column in descendingorder. False to sort ascending.

groupBy

True to specify that the column should alsobe grouped by, as well as sorted.

Return Value

The position into which the new element wasinserted.

UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];

 

// Sort the rows by Country and City fields. Noticethe order in which these columns

// are set. We want to sort by Country and then sortby City and in order to do that

// we have to set the SortIndicator property in theright order.

band.Columns["Country"].SortIndicator= SortIndicator.Ascending;

band.Columns["City"].SortIndicator   = SortIndicator.Ascending;

 

// You can also sort (as well as group rows by)columns by using SortedColumns

// property off the band.

band.SortedColumns.Add( "ContactName",false, false );

 

AllowRowSummaries

手动添加汇总

UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[2];

 

           //Set the AllowRowSummaries to either True or BasedOnDataType to allow

           //the user to be able to add, remove or modify summaries. This is not

           //necessary to create summaries programmatically and only effects the

           //users ability to create, remove or modify summaries.

//按数据类型进行汇总

           band.Override.AllowRowSummaries= AllowRowSummaries.BasedOnDataType;

 

           //You can also prevent the user from adding, removing or modifying a

           //summary on a column basis. Prevent the user from summarizing OrderID

           //column.

           band.Columns["OrderID"].AllowRowSummaries = AllowRowSummaries.False;

           band.Columns["ProductID"].AllowRowSummaries = AllowRowSummaries.False;

           

           //Add summaries. Notice the keys "Max" and "Avg". We will usethem to

           //identify the summaries later on for example in SummaryValueChanged

           //event.

           SummarySettingsmaxSummary = band.Summaries.Add( "Max",SummaryType.Maximum, band.Columns["Unit Price"] );

           SummarySettingsavgSummary = band.Summaries.Add( "Avg",SummaryType.Average, band.Columns["Unit Price"] );

 

           //Set the format of the summary text

           maxSummary.DisplayFormat= "Min = {0:#####.00}";

           avgSummary.DisplayFormat= "Avg = {0:#####.00}";

band.Summaries["PairsSum"].DisplayFormat="{0:#####}";

汇总栏格式,不要前面 汇总类型

 

           //Change the appearance settings for summaries.

           maxSummary.Appearance.TextHAlign= HAlign.Right;

           avgSummary.Appearance.TextHAlign= HAlign.Right;           

 

           //Set the DisplayInGroupBy property of both summaries to false so they don‘t

           //show up in group-by rows.

           maxSummary.DisplayInGroupBy= false;

           avgSummary.DisplayInGroupBy= false;

 

           //Set the caption that shows up on the header of the summary footer.

           band.SummaryFooterCaption= "Summary of Unit Price";

           band.Override.SummaryFooterCaptionAppearance.FontData.Bold= DefaultableBoolean.True;

           band.Override.SummaryFooterCaptionAppearance.BackColor= Color.DarkBlue;

           band.Override.SummaryFooterCaptionAppearance.ForeColor= Color.LightYellow;

 

让UltraWinGrid的列以控件形式表现出来

 

 

进度条显示

 

ugSchedule.DisplayLayout.Bands["Schedule"].Columns["Progress"].EditorControl= new Infragistics.Win.UltraWinProgressBar.UltraProgressBar();

 

Infragistics.Win.UltraWinProgressBar.UltraProgressBarpbar = new Infragistics.Win.UltraWinProgressBar.UltraProgressBar();

pbar.UseOsThemes= Infragistics.Win.DefaultableBoolean.False;

pbar.Style =Infragistics.Win.UltraWinProgressBar.ProgressBarStyle.Continuous;

pbar.FillAppearance.ForeColor= Color.Red;

band.Columns["Progress"].Header.Caption= "完成度";

band.Columns["Progress"].Width= 80;

band.Columns["Progress"].EditorControl= pbar;

band.Columns["Progress"].CellAppearance.TextHAlign= HAlign.Center;

 

计算器

 

     columns[2].EditorControl =this.ultraCalculatorDropDown1;

 

动态设定列选择项

 

ValueLists =ugOfficialPo.DisplayLayout.ValueLists;

ValueLists.Add("Group");

ValueLists["Group"].ValueListItems.Add("A");

ValueLists["Group"].ValueListItems.Add("B");

ugOfficialPo.DisplayLayout.Bands["InquiryPo"].Columns["Group"].ValueList= ValueLists["Group"];

限制只能使用上面ValueList里的值

Band.Columns["Group"].Style= Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;

 

隐藏GroupHeader

 

band.GroupHeadersVisible = false;

 

使某列不出现在ColumnChooser

 

 

band.Columns["Status"].ExcludeFromColumnChooser= ExcludeFromColumnChooser.True

UltraWinGrid使用TIPS(转载)

上一篇:SQL Server数据仓库的基础架构规划


下一篇:【转帖】使用容器化和 Docker 实现 DevOps 的基础知识