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+ 筆資料仍流暢。