public TableForm(ocNet.Lib.DBTable.Table table) { this.table = table; InitializeComponent(); //(dataGrid.Columns[0] as DataGridTextColumn).Binding = new Binding("FieldID"); testList = new List <Test>(); foreach (var field in table.Fields) { Test curTest = new Test(field.ID, field.Type, field.Length); testList.Add(curTest); //dataGrid.Items.Add(curTest); } dataGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn; //dataGrid.ItemsSource = testList; /* * * * AddColumn(0, "FieldID", "FieldID"); * AddColumn(2, "FieldType", "FieldType"); * AddColumn(0, "Length", "Length"); * AddColumn(0, "Decimals", "Decimals"); * AddColumn(1, "PID", "PID"); * AddColumn(1, "Zerofill", "Zerofill"); */ dataGrid.PreviewMouseLeftButtonDown += DataGrid_PreviewMouseLeftButtonDown; dataGrid.Drop += DataGrid_Drop; dataGrid.DragOver += DataGrid_DragOver; dataGrid.MouseDoubleClick += DataGrid_MouseDoubleClick; dataGrid.BeginningEdit += DataGrid_BeginningEdit; dataGrid.LoadingRow += DataGrid_LoadingRow; dataGrid.LoadingRowDetails += DataGrid_LoadingRowDetails; foreach (var di in testList) { dataGrid.Items.Add(di); } /* * * * DataTrigger trigger = new DataTrigger(); * trigger.Value = "Decimals"; * Setter set = new Setter(); * set.Property = Control.ForegroundProperty; * set.Value = "Gray"; * trigger.Setters.Add(set); * * * * dataGrid.Columns[0].CellStyle.Triggers.Add(trigger); * */ /* * SmartTableControl tc = new SmartTableControl(); * tc.AddColumn(20, "PIDThatIsMuchToLong"); * tc.AddColumn(50, "FieldTypeForAnotherMuchToLongHeaderField"); * tc.AddColumn(20, "AnotherField"); * * tc.AddRow(); * tc.AddRow(); * tc.AddRow(); * tc.AddRow(); * tc.AddRow(); * tc.AddRow(); * * (Content as Grid).Children.Add(tc); * * tc.GetCellText = GetCellTextHandler; */ }
public TableForm(ocNet.Lib.DBTable.Table table) { this.table = table; InitializeComponent(); //(dataGrid.Columns[0] as DataGridTextColumn).Binding = new Binding("FieldID"); testList = new List<Test>(); foreach(var field in table.Fields) { Test curTest = new Test(field.ID, field.Type, field.Length); testList.Add(curTest); //dataGrid.Items.Add(curTest); } dataGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn; //dataGrid.ItemsSource = testList; /* AddColumn(0, "FieldID", "FieldID"); AddColumn(2, "FieldType", "FieldType"); AddColumn(0, "Length", "Length"); AddColumn(0, "Decimals", "Decimals"); AddColumn(1, "PID", "PID"); AddColumn(1, "Zerofill", "Zerofill"); */ dataGrid.PreviewMouseLeftButtonDown += DataGrid_PreviewMouseLeftButtonDown; dataGrid.Drop += DataGrid_Drop; dataGrid.DragOver += DataGrid_DragOver; dataGrid.MouseDoubleClick += DataGrid_MouseDoubleClick; dataGrid.BeginningEdit += DataGrid_BeginningEdit; dataGrid.LoadingRow += DataGrid_LoadingRow; dataGrid.LoadingRowDetails += DataGrid_LoadingRowDetails; foreach(var di in testList) { dataGrid.Items.Add(di); } /* DataTrigger trigger = new DataTrigger(); trigger.Value = "Decimals"; Setter set = new Setter(); set.Property = Control.ForegroundProperty; set.Value = "Gray"; trigger.Setters.Add(set); dataGrid.Columns[0].CellStyle.Triggers.Add(trigger); */ /* SmartTableControl tc = new SmartTableControl(); tc.AddColumn(20, "PIDThatIsMuchToLong"); tc.AddColumn(50, "FieldTypeForAnotherMuchToLongHeaderField"); tc.AddColumn(20, "AnotherField"); tc.AddRow(); tc.AddRow(); tc.AddRow(); tc.AddRow(); tc.AddRow(); tc.AddRow(); (Content as Grid).Children.Add(tc); tc.GetCellText = GetCellTextHandler; */ }