private void MainWindow_Load(object sender, EventArgs e) { //new RemoteXMLReader(); //Downloader.DownloadFile("http://www.rimtengg.com/coit2007/proceedings/pdfs/108.pdf", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Download_Progress); conn.Open(); flowLayoutPanelHeight = flpControls.Height; dataGridViewHeight = dataGridView.Height; dgvp = new DataGridViewProperties(dataGridView); // refactor dgvp.bindEvents(); dataGridView.CurrentCellChanged += new System.EventHandler(this.dataGridView_CurrentCellChanged); this.dataGridView.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_RowHeaderMouseClick); adapter.SelectCommand = new OleDbCommand("Select * from Stock", conn); adapter.Fill(dgvp.dataSet, "Stocks"); conn.Close(); DataColumnCollection columns = dgvp.dataSet.Tables["Stocks"].Columns; foreach (DataRow dataRow in dgvp.dataSet.Tables["Stocks"].Rows) { String text = dataRow.ItemArray[columns.IndexOf("text")].ToString(); String name = text.Replace(" ", ""); ToolStripMenuItem tsmi = new ToolStripMenuItem(text, tsmiStock.Image, tsmiStock_Click, "tsmiStock" + name); tsmi.Tag = dataRow.ItemArray[columns.IndexOf("id")].ToString(); ToolStripItem[] items = new ToolStripItem[tsmiStock.DropDownItems.Count]; tsmiStock.DropDownItems.CopyTo(items, 0); foreach (ToolStripItem c in items) { tsmi.DropDownItems.Add(c); } if (tsmiStock.Tag == null) { setCurrentStock(tsmi); conn.Open(); DBSelect_LoadingLists_Reset(); conn.Close(); tsmiStock_Click(tsmi, new EventArgs()); } tsmiStock1.DropDownItems.Insert(tsmiStock1.DropDownItems.IndexOf(tsmiStock), tsmi); } /* CalendarCell datePicker = new CalendarCell(); int index = dataSet.Tables["TestTable"].Columns.IndexOf("added_at"); dataGridView.Columns[index].Visible = false; dataGridView.Columns.Insert(index, DataGridViewDat); dataGridView.Columns[index].DataPropertyName = "added_at"; DataGridViewComboBoxColumn comboBox = new DataGridViewComboBoxColumn(); comboBox.HeaderText = "Type"; comboBox.DropDownWidth = 90; comboBox.Width = 90; comboBox.MaxDropDownItems = 5; comboBox.Items.AddRange("77", "88", "99"); int index = dataSet.Tables["TestTable"].Columns.IndexOf("wh_number"); dataGridView.Columns[index].Visible = false; dataGridView.Columns.Insert(index, comboBox); dataGridView.Columns[index].DataPropertyName = "wh_number"; */ }
public static void DataGridView_LockColumn(DataGridViewProperties dataGridViewProperties, String name) { int index = dataGridViewProperties.IndexOf(name); if (index > -1 && index < dataGridViewProperties.dataGridView.Columns.Count) { DataGridViewColumn readOnlyColumn = dataGridViewProperties.dataGridView.Columns[index]; readOnlyColumn.ReadOnly = true; readOnlyColumn.DefaultCellStyle.BackColor = Color.WhiteSmoke; } }
public static float dataGridView_ColumnSum(DataGridViewProperties properties, String name) { float sum = 0F; foreach (DataGridViewRow row in properties.dataGridView.Rows) { float number = 0; float.TryParse(row.Cells[properties.IndexOf(name)].Value.ToString(), out number); sum += number; } return sum; }