1. 程式人生 > >UltraWinGrid單元格控制元件

UltraWinGrid單元格控制元件

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

手動增加排序並分組

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

 :https://www.sogou.com/linkurl=DOb0bgH2eKh1ibpaMGjuy7jbLbAmegn_omDqaPMNTWOuSdKpCMIsLny_GD_6DQHAPv0GKsyTiRU.