void Form1_Load(object sender, System.EventArgs e) { // bind grid to a data source string conn = GetConnectionString(); OleDbDataAdapter da = new OleDbDataAdapter("select * from products", conn); DataTable dt = new DataTable("Products"); da.Fill(dt); _flex.DataSource = dt; // hide ID columns so the bars stand out more foreach (Column col in _flex.Cols) { if (col.Name.EndsWith("ID")) { col.Visible = false; } } // attach scaling info to each numeric column int r1 = _flex.Rows.Fixed; int r2 = _flex.Rows.Count - 1; string[] barCols = new string[] { "UnitPrice", "UnitsInStock", "UnitsOnOrder", "ReorderLevel" }; foreach (string s in barCols) { Column col = _flex.Cols[s]; double max = _flex.Aggregate(AggregateEnum.Max, r1, col.Index, r2, col.Index); col.UserData = max; } // turn on ownerdraw _flex.DrawMode = DrawModeEnum.OwnerDraw; }