/// <summary> /// 初始化ReoGrid表格,注意:只会保留KeyName中Visible=true的列和"ID"列! /// </summary> /// <param name="reoGrid"></param> /// <param name="keyNames"></param> /// <param name="selectionMode"></param> public static void InitReoGrid(ReoGridControl reoGrid, KeyName[] keyNames, WorksheetSelectionMode selectionMode = WorksheetSelectionMode.Row) { //初始化表格 reoGrid.SetSettings(WorkbookSettings.View_ShowSheetTabControl, false); var worksheet = reoGrid.Worksheets[0]; worksheet.SelectionMode = selectionMode; keyNames = (from kn in keyNames where kn.Visible == true || kn.Key == "ID" select kn).ToArray(); for (int i = 0; i < keyNames.Length; i++) { worksheet.ColumnHeaders[i].Text = keyNames[i].Name; worksheet.ColumnHeaders[i].IsVisible = keyNames[i].Visible; } worksheet.Columns = keyNames.Length; //限制表的长度 }
public MainWindow() { InitializeComponent(); // Wrap winform control into WPF var grid = new ReoGridControl { Dock = DockStyle.Fill, }; WindowsFormsHost.Child = grid; // Hide sheet tab control grid.SetSettings(WorkbookSettings.View_ShowSheetTabControl, false); DataContext = new MainWindowViewModel(grid.Worksheets[0]); ViewModel = (MainWindowViewModel)DataContext; ContentRendered += MainWindow_ContentRendered; // SearchTextBox settings---------------------------------------------------- // Supply the control with the list of sections var sections = new List <string> { "All", "Companies", "Requisites", "Contact persons", "License", "Products", "Contracts", "Additional info" }; SearchTextBox.SectionsList = sections; // Choose a style for displaying sections SearchTextBox.SectionsStyle = SearchTextBox.SectionsStyles.CheckBoxStyle; // Add a routine handling the event OnSearch SearchTextBox.OnSearch += OnSearch; // -------------------------------------------------------------------------- }