//------------------------------------------------------------------- void PopulateDB( MemManager.Log.Log log ) { DataSet myDataSet = new DataSet("DataSet"); DataTable table; DataColumn column; DataGridColumnStyle columnstyle; string cats = "1Index|"; if (mCategoryMode) cats += "0Category|"; else cats += "0Heap|"; // cats+= "0Name|1Alignment|1ActualSize|1Count|1TotalSize"; cats += "0Name|1ActualSize|1Count|1TotalSize"; DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = "All"; tableStyle.RowHeaderWidth = 10; tableStyle.AlternatingBackColor = System.Drawing.Color.FromArgb(((System.Byte)(250)), ((System.Byte)(250)), ((System.Byte)(250))); table = new DataTable( "All" ); table.BeginLoadData(); foreach (string s in cats.Split('|')) { string n = s.Substring(1); //if (n == "Index") // continue; column = new DataColumn(); column.ColumnName = n; column.ReadOnly = true; column.Unique = false; if (s[0] == '0') { column.DataType = System.Type.GetType("System.String"); columnstyle = new DataGridTextBoxColumn(); } else if (s[0] == '1') { column.DataType = System.Type.GetType("System.Int32"); columnstyle = new DataGridTextBoxColumn(); } else //if (s[0] == '2') { column.DataType = System.Type.GetType("System.Boolean"); columnstyle = new DataGridBoolColumn(); } table.Columns.Add(column); columnstyle.MappingName = n; columnstyle.HeaderText = n; columnstyle.Width = 70; if (n == "Name") columnstyle.Width = 360; else if (n == "Heap") columnstyle.Width = 70; else if (n == "Category") columnstyle.Width = 90; else if (n == "Count" ) //|| n == "Alignment") columnstyle.Width = 42; tableStyle.GridColumnStyles.Add( columnstyle ); } for (int j = 0; j < mCollapsedView.Count; j++) { Item item = (Item)mCollapsedView[j]; MemManager.Log.LogEntry le_a = log[item.index]; string allocatorName = log.GetAllocator(le_a.allocator); string categoryName = mCategoryMode ? log.GetCategory(le_a.category) : log.GetCategory(0); DataRow row = table.NewRow(); row["Index"] = item.index; if (mCategoryMode) row["Category"] = categoryName; else row["Heap"] = allocatorName; // string removalString = log.GetAllocator(item.allocator) + "::"; // if (mCategoryMode) // removalString += categoryName + "::"; row["Name"] = log.GetString(le_a.nameString); //.Substring(removalString.Length); // row["Alignment"] = item.alignment; // row["ReqSize"] = item.requestedSize; row["ActualSize"] = le_a.allocSize; row["Count"] = item.count; row["TotalSize"] = item.count * le_a.allocSize; table.Rows.Add(row); } table.EndLoadData(); // Add the table to the dataset myDataSet.Tables.Add(table); // Make the dataGrid use our new table style and bind it to our table mDataGrid.TableStyles.Clear(); mDataGrid.TableStyles.Add(tableStyle); // Set up grid bindings mDataGrid.SetDataBinding(myDataSet, "All"); // Update status UpdateStatusBar(); }