private int index; // index to Professionbuddy.Instance.TradeSkillList public TradeSkillListView(int index) { this.index = index; // Filter TextBox FilterText = new TextBox(); FilterText.Dock = DockStyle.Fill; // Category Combobox CategoryCombo = new ComboBox(); CategoryCombo.Dock = DockStyle.Fill; // columns NameColumn = new DataGridViewTextBoxColumn(); CraftableColumn = new DataGridViewTextBoxColumn(); DifficultyColumn = new DataGridViewTextBoxColumn(); NameColumn.HeaderText = "Name"; CraftableColumn.HeaderText = "#"; NameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; CraftableColumn.MinimumWidth = 25; CraftableColumn.Width = 25; DifficultyColumn.MinimumWidth = 25; DifficultyColumn.Width = 25; // DataGridView TradeDataView = new DataGridView(); TradeDataView.Dock = DockStyle.Fill; TradeDataView.AllowUserToAddRows = false; TradeDataView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; TradeDataView.RowHeadersVisible = false; TradeDataView.Columns.Add(NameColumn); TradeDataView.Columns.Add(CraftableColumn); TradeDataView.Columns.Add(DifficultyColumn); TradeDataView.AllowUserToResizeRows = false; TradeDataView.EditMode = DataGridViewEditMode.EditProgrammatically; TradeDataView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; TradeDataView.ColumnHeadersHeight = 21; TradeDataView.RowTemplate.Height = 16; //table layout tabTableLayout = new TableLayoutPanel(); tabTableLayout.ColumnCount = 2; tabTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tabTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tabTableLayout.RowCount = 2; tabTableLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); tabTableLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tabTableLayout.Controls.Add(FilterText, 0, 0); tabTableLayout.Controls.Add(CategoryCombo, 1, 0); tabTableLayout.Controls.Add(TradeDataView, 0, 1); tabTableLayout.Dock = DockStyle.Fill; tabTableLayout.SetColumnSpan(TradeDataView, 2); // tab this.Controls.Add(tabTableLayout); this.Text = Professionbuddy.Instance.TradeSkillList[index].Name; // populate the controls with data CategoryCombo.Items.Add(""); // blank line will show all headers... foreach (KeyValuePair <uint, Recipe> kv in Professionbuddy.Instance.TradeSkillList[index].Recipes) { if (!CategoryCombo.Items.Contains(kv.Value.Header)) { CategoryCombo.Items.Add(kv.Value.Header); } TradeDataView.Rows.Add(new TradeSkillRecipeCell(index, kv.Key), Util.CalculateRecipeRepeat(kv.Value), (int)kv.Value.Difficulty); // make color column sortable by dificulty.. } TradeDataView_SelectionChanged(null, null); // hook events FilterText.TextChanged += new EventHandler(FilterText_TextChanged); CategoryCombo.SelectedValueChanged += new EventHandler(SectionCombo_SelectedValueChanged); TradeDataView.SelectionChanged += new EventHandler(TradeDataView_SelectionChanged); TradeDataView.CellFormatting += new DataGridViewCellFormattingEventHandler(TradeDataView_CellFormatting); }