首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

OutlookGrid 進階功能與非綁定模式操作(四):分組摺疊/展開、清除分組、圖示自訂與非綁定資料排序

     編輯:關於C語言

分組狀態控制方法

  • CollapseAll():摺疊所有群組,僅顯示群組標題。
  • ExpandAll():展開所有群組。
  • ClearGroups():移除所有分組,僅顯示明細列。

圖示自訂

  • CollapseIcon / ExpandIcon:設定群組展開/摺疊圖示(+/-),設為 null 則不繪製。

非綁定模式建立資料與排序

// 清除舊繫結
outlookGrid1.BindData(null, null);
// 建立欄位
outlookGrid1.Columns.Add("column1", "Id");
outlookGrid1.Columns.Add("column2", "Name");
// 建立列(必須使用 OutlookGridRow)
var row1 = new OutlookGridRow();
row1.CreateCells(outlookGrid1, id1, name1);
outlookGrid1.Rows.Add(row1);

var row2 = new OutlookGridRow();
row2.CreateCells(outlookGrid1, id2, name2);
outlookGrid1.Rows.Add(row2);

// 排序:兩種方式
// 1. 使用 OutlookGridRowComparer
outlookGrid1.Sort(new OutlookGridRowComparer(columnIndex, sortDirection));
// 2. 直接指定欄位與方向
outlookGrid1.Sort(outlookGrid1.Columns[columnIndex], sortDirection);

非綁定模式下排序依賴 OutlookGridRowComparer 比較儲存格字串值,或使用簡化的 Sort 多載。測試 2000+ 筆資料仍流暢。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved