private void LoadDgv() { dataGridView1.Columns.Add("btns", "BTNS"); FontFamilyCB.DisplayMember = "Name"; DataGridViewButtonColumn button = new DataGridViewButtonColumn(); { button.Name = "button"; button.HeaderText = "Button"; button.Text = "Button"; dataGridView1.Columns.Add(button); } foreach (System.Drawing.FontFamily font in System.Drawing.FontFamily.Families) { FontFamilyCB.Items.Add(font); DataGridViewButtonCell b = new DataGridViewButtonCell(); int rowIndex = dataGridView1.Rows.Add(b); dataGridView1.Rows[rowIndex].Cells["button"].Style.Font = new Font(font, 11, FontStyle.Regular); // each cell will have his own font-family dataGridView1.Rows[rowIndex].Cells["button"].Value = "A"; } }
private void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { DataGridView dataGridView = sender as DataGridView; int columnIndex = e.ColumnIndex; int rowIndex = e.RowIndex; if (rowIndex % 2 == 1) { dataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = Color.LightGray; } else { dataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = Color.White; } DataGridViewButtonCell dataGridViewButtonCell = dataGridView.Rows[rowIndex].Cells[columnIndex] as DataGridViewButtonCell; if (rowIndex < this.DataTable.Rows.Count && dataGridView.Columns[columnIndex] is DataGridViewButtonColumn && dataGridViewButtonCell != null) { dataGridViewButtonCell.FlatStyle = FlatStyle.Popup; dataGridViewButtonCell.Style.Font = new Font(this.Font.SystemFontName, 7f, FontStyle.Bold); dataGridViewButtonCell.Style.ForeColor = Color.White; dataGridViewButtonCell.Style.BackColor = this.COLOR_DELETE_BUTTON; } }
public void load_Cells(List <int> _list_closedCells) { list_closedCells = _list_closedCells; cells = new byte[numberOfColumns, numberOfRows]; int height = (dataGridView_closedCells.Height - 2) / numberOfRows; DataGridViewButtonColumn[] columns = new DataGridViewButtonColumn[numberOfColumns]; for (int numberColumn = 0; numberColumn <= numberOfColumns - 1; numberColumn++) { columns[numberColumn] = new DataGridViewButtonColumn(); dataGridView_closedCells.Columns.Add(columns[numberColumn]); } for (int numberRow = 0; numberRow < numberOfRows; numberRow++) { dataGridView_closedCells.Rows.Add(); dataGridView_closedCells.Rows[numberRow].Height = height; } int k = 1; for (int numberRow = 0; numberRow < numberOfRows; numberRow++) { for (int numberColumn = 0; numberColumn <= numberOfColumns - 1; numberColumn++) { DataGridViewButtonCell buttonCell = (DataGridViewButtonCell)dataGridView_closedCells.Rows[numberRow].Cells[numberColumn]; buttonCell.Value = k; if (list_closedCells.Any(db => db.Equals(k))) { cells[numberColumn, numberRow] = 2; paintCell(buttonCell); } k++; } } }
private void dgvExecutors_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { DataGridView grid = (DataGridView)sender; DataGridViewColumn column = grid.Columns[e.ColumnIndex]; DataGridViewRow row = grid.Rows[e.RowIndex]; DataGridViewCell cell = grid[e.ColumnIndex, e.RowIndex]; switch (column.Name) { case "PersonCode": frmBrigadePersons fbp = new frmBrigadePersons(); fbp.CatalogMode = CatalogMode.Select; fbp.ctrlBrigadePersons.BrigadeId = this.BrigadeId; List <BrigadePerson> deletions = new List <BrigadePerson>(); List <short> deletionsCodes = new List <short>(); foreach (DataGridViewRow r in this.dgvItems.Rows) { deletionsCodes.Add(Convert.ToInt16(r.Cells["PersonCode"].Value)); } foreach (short deletionCode in deletionsCodes) { deletions.AddRange(Databases.Tables.BrigadePersons.Active.Where(r => r.Person.Code == deletionCode).AsEnumerable()); } fbp.ctrlBrigadePersons.Deletions = deletions; fbp.ShowDialog(); if (fbp.ctrlBrigadePersons.SelectedId != 0) { BrigadePerson brigadePerson = Databases.Tables.BrigadePersons[fbp.ctrlBrigadePersons.SelectedId]; DataGridViewButtonCell button = (DataGridViewButtonCell)cell; button.Value = brigadePerson.Person.Code.ToString(); button.Tag = brigadePerson.Person; row.Cells["PersonLastName"].Value = brigadePerson.Person.LastName; row.Cells["PersonFirstName"].Value = brigadePerson.Person.FirstName; row.Cells["PersonMiddleName"].Value = brigadePerson.Person.MiddleName; } break; case "ProfessionCode": if (row.Cells["PersonCode"].Value != null) { frmPersonProfessions ppf = new frmPersonProfessions(); Person p = ((DataGridViewButtonCell)row.Cells["PersonCode"]).Tag as Person; ppf.ctrlPersonProfessions.PersonId = p.Id; ppf.ShowDialog(); if (ppf.SelectedId != 0) { PersonProfession pp = Databases.Tables.PersonProfessions[ppf.SelectedId]; DataGridViewButtonCell b = (DataGridViewButtonCell)cell; b.Tag = pp; b.Value = pp.Profession.Code.ToString(); grid.CurrentCell = row.Cells["Rank"]; grid.BeginEdit(true); DataGridViewTextBoxEditingControl rankControl = (DataGridViewTextBoxEditingControl)grid.EditingControl; rankControl.Text = pp.Rank.ToString(); grid.EndEdit(); } } break; default: break; } } }
public static void PopulateRow(DataGridView dgPublishes, int rownumber, ComputerStatus compstatus, ContextMenuStrip ctx) { string machineName = compstatus.msg.machineName; List <string> publishes = compstatus.msg.availablePublishes; string status = compstatus.msg.statusText; WatchdogStatusMessage.StatusLevel statusType = compstatus.msg.statusLevel; string curPublishName = compstatus.msg.curPublishName; DataGridViewTextBoxCell cellMachineName = (DataGridViewTextBoxCell)dgPublishes["MachineName", rownumber]; DataGridViewComboBoxCell cellAvailablePublishes = (DataGridViewComboBoxCell)dgPublishes["AvailablePublishes", rownumber]; DataGridViewImageCell cellStatus = (DataGridViewImageCell)dgPublishes["Status", rownumber]; DataGridViewTextBoxCell cellStatusDetail = (DataGridViewTextBoxCell)dgPublishes["StatusDetail", rownumber]; DataGridViewButtonCell cellPublish = (DataGridViewButtonCell)dgPublishes["RePublish", rownumber]; DataGridViewButtonCell cellExecute = (DataGridViewButtonCell)dgPublishes["Execute", rownumber]; DataGridViewButtonCell cellStop = (DataGridViewButtonCell)dgPublishes["Stop", rownumber]; if (cellPublish.FlatStyle != FlatStyle.Flat) { cellPublish.Value = "Publish"; cellPublish.ReadOnly = true; cellPublish.FlatStyle = FlatStyle.Flat; cellExecute.Value = "Execute"; cellExecute.ReadOnly = true; cellExecute.FlatStyle = FlatStyle.Flat; cellStop.Value = "Stop"; cellStop.ReadOnly = true; cellStop.FlatStyle = FlatStyle.Flat; cellStatus.ContextMenuStrip = ctx; cellStatusDetail.ContextMenuStrip = ctx; cellMachineName.ContextMenuStrip = ctx; cellPublish.ContextMenuStrip = ctx; } if (((string)cellMachineName.Value) != machineName) { cellMachineName.Value = machineName; cellMachineName.ReadOnly = true; } //remember the selected publish object o = null; if (cellAvailablePublishes.Value != null) { o = cellAvailablePublishes.Value; } if (cellAvailablePublishes.FlatStyle != FlatStyle.Flat) { cellAvailablePublishes.FlatStyle = FlatStyle.Flat; } if (publishes != null && publishes.Count > 0) { foreach (string p in publishes) { if (cellAvailablePublishes.Items.Contains(p) == false) { cellAvailablePublishes.Items.Add(p); } } List <string> duds = new List <string>(); foreach (string p in cellAvailablePublishes.Items) { if (publishes.Contains(p) == false) { duds.Add(p); } } foreach (string p in duds) { cellAvailablePublishes.Items.Remove(p); } } string pref = null; foreach (PreferredLocation ploc in PublishManager.settings.PreferredRemotePublish) { if (ploc.computername.ToLower().Equals(machineName.ToLower())) { pref = ploc.publishname; } } if (publishes.Count == 0) { cellAvailablePublishes.Value = ""; } //show the last selected one... else if ((o != null) && (publishes.Contains((string)o))) { cellAvailablePublishes.Value = o; } //show the one that is running else if (((o == null) || (((string)o) == "")) && publishes.Contains(curPublishName)) { cellAvailablePublishes.Value = curPublishName; } //show the preffered else if (pref != null && publishes.Contains(pref)) { cellAvailablePublishes.Value = pref; } //show the first else if (cellAvailablePublishes.Items.Count > 0) { cellAvailablePublishes.Value = cellAvailablePublishes.Items[0]; } string statusDetail = curPublishName + ": " + status; if (curPublishName == "") { statusDetail = status; } if (compstatus.isPublishing) { statusDetail = "Publishing...."; } if (((string)cellStatusDetail.Value) != statusDetail) { cellStatusDetail.Value = statusDetail; if (compstatus.isPublishing == false) { switch (statusType) { case WatchdogStatusMessage.StatusLevel.Error: cellStatus.Value = Properties.Resources.yellowlight; break; case WatchdogStatusMessage.StatusLevel.NotRunning: cellStatus.Value = Properties.Resources.redlight; break; case WatchdogStatusMessage.StatusLevel.Running: cellStatus.Value = Properties.Resources.greenlight; break; case WatchdogStatusMessage.StatusLevel.NoConnection: cellStatus.Value = Properties.Resources.noconnect; break; } } else { cellStatus.Value = Properties.Resources.publishing; } } }
private void BindData(string filePath) { Dictionary <int, double> valuesPrice = new Dictionary <int, double>(); RefreshGrid(); string[] lines = System.IO.File.ReadAllLines(filePath); if (lines.Length > 0) { //first line to create header string firstLine = lines[0]; string[] headerLabels = firstLine.Split(';'); var c = 0; foreach (string headerWord in headerLabels) { if (headerWord.ToLower() == "binding") { DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn(); combo.Name = headerWord; combo.HeaderText = headerWord; combo.DataPropertyName = headerWord; combo.Width = 100; dataGridView1.Columns.Insert(c, combo); } else if (headerWord.ToLower() == "description") { DataGridViewButtonColumn btn = new DataGridViewButtonColumn(); btn.Name = headerWord; btn.HeaderText = headerWord; btn.DataPropertyName = headerWord; btn.Width = 100; btn.UseColumnTextForButtonValue = true; dataGridView1.Columns.Insert(c, btn); } else if (headerWord.ToLower() == "in stock") { DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn(); chk.Name = headerWord; chk.HeaderText = headerWord; chk.DataPropertyName = headerWord; chk.Width = 100; dataGridView1.Columns.Insert(c, chk); } else { DataGridViewTextBoxColumn text = new DataGridViewTextBoxColumn(); text.Name = headerWord; text.HeaderText = headerWord; text.DataPropertyName = headerWord; text.Width = 100; dataGridView1.Columns.Insert(c, text); } c++; } //For Data for (int i = 1, j = 0; i < lines.Length; i++, j++) { string[] dataWords = lines[i].Split(';'); DataGridViewRow dgr = new DataGridViewRow(); int columnIndex = 0; int rowIndex = 0; this.dataGridView1.Rows.Add(); foreach (string headerWord in headerLabels) { var word = dataWords[columnIndex++]; if (headerWord.ToLower() == "description") { DataGridViewButtonCell btn = new DataGridViewButtonCell(); //btn.Value = word; btn.ToolTipText = word; btn.UseColumnTextForButtonValue = true; this.dataGridView1.Rows[j].Cells[rowIndex] = btn; } if (headerWord.ToLower() == "binding") { DataGridViewComboBoxCell combo = new DataGridViewComboBoxCell(); combo.Items.Add(word); combo.Value = word; this.dataGridView1.Rows[j].Cells[rowIndex] = combo; } else if (headerWord.ToLower() == "in stock") { DataGridViewCheckBoxCell check = new DataGridViewCheckBoxCell(); if (word == "yes") { check.Value = true; } this.dataGridView1.Rows[j].Cells[rowIndex] = check; if (word == "no") { this.dataGridView1.Rows[j].DefaultCellStyle.BackColor = Color.Red; rowsToRemove.Add(this.dataGridView1.Rows[j]); } } else { this.dataGridView1.Rows[j].Cells[rowIndex].Value = word; if (headerWord.ToLower() == "price") { string value = word.Replace(",", "."); valuesPrice.Add(i, double.Parse(value)); } } rowIndex++; } } } var columnList = dataGridView1.Columns.Cast <DataGridViewColumn>().ToList(); int indexPrice = columnList.FindIndex(c => c.HeaderText == "Price"); var sortedvaluesPrice = (from entry in valuesPrice orderby entry.Value ascending select entry); int val = 0; foreach (var item in sortedvaluesPrice) { dataGridView1.Rows[item.Key].Cells[indexPrice].Style.ForeColor = Color.FromArgb(255, val, val, val); val += 30; } dataGridView1.CellClick += dataGridView1_CellClick; }
// Add line to param list button event handler private void addPlotData_Click(object sender, EventArgs e) { try { // Obtain source data file string dataSource = ""; OpenFileDialog selectFileDialog = new OpenFileDialog(); if (defaultDirectory == String.Empty) { selectFileDialog.InitialDirectory = "C:\\"; } else { selectFileDialog.InitialDirectory = defaultDirectory; } selectFileDialog.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*"; selectFileDialog.FilterIndex = 1; if (selectFileDialog.ShowDialog() == DialogResult.OK) { dataSource = selectFileDialog.FileName; defaultDirectory = dataSource.Trim().Remove(dataSource.LastIndexOf(@"\")); } // Create the plot settings and update GUI if (plotTypeDropDownBox.SelectedIndex == 0) { plotList.Add(new DataPlotSettings(dataSource)); } else if (plotTypeDropDownBox.SelectedIndex == 1) { if (plotSettingsDataGridView.Rows.Count != 0) { throw new Exception("Frequency plotting will only use the first input data set."); } plotList.Add(new FreqPlotSettings(dataSource)); } else { throw new Exception("Invalid plot type selection"); } plotSettingsDataGridView.Rows.Add(); plotSettingsDataGridView[0, plotList.Count - 1].Value = plotList[plotList.Count - 1].DataFilePath.Trim(). Remove(plotList[plotList.Count - 1].DataFilePath.LastIndexOf(@".")). Remove(0, plotList[plotList.Count - 1].DataFilePath.LastIndexOf(@"\") + 1); DataGridViewButtonCell plotOptionsCell = (DataGridViewButtonCell)plotSettingsDataGridView[4, plotList.Count - 1]; plotOptionsCell.Value = "Options..."; plotSettingsDataGridView[1, plotList.Count - 1].Value = 0; if (!removePlotData.Enabled) { removePlotData.Enabled = true; } if (!submitButton.Enabled) { submitButton.Enabled = true; } } catch (System.ArgumentException) { return; } catch (System.Exception) { throw; } }
public void UpdateEquipmentGrid(object character, ComboBox equipmentList, List <uint> equippedItems, FFRKViewPartyPlanner.Synergy realmSynergy) { mCharacter = (GameData.DataBuddyInformation)character; mEquipmentList = equipmentList; mEquippedItems = equippedItems; bool characterHasSynergy = mCharacter != null && (mCharacter.SeriesId == realmSynergy.SeriesId || mCharacter.EligibleForNightmareShift(realmSynergy.NightmareCategory)); for (int i = 0; i < comboBoxRealmSynergy.Items.Count; i++) { if (((FFRKViewPartyPlanner.Synergy)comboBoxRealmSynergy.Items[i]).SeriesId == realmSynergy.SeriesId) { comboBoxRealmSynergy.SelectedIndex = i; break; } } dataGridViewEquipment.Rows.Clear(); foreach (GameData.Party.DataEquipmentInformation item in equipmentList.Items) { bool itemHasSynergy = item.SeriesId == realmSynergy.SeriesId || mCharacter.EligibleForNightmareShift(realmSynergy.NightmareCategory); bool itemEquippedElsewhere = equippedItems.Any(equippedItemId => equippedItemId == item.InstanceId); DataGridViewRow row = new DataGridViewRow(); row.Tag = item; DataGridViewCell cell = new DataGridViewButtonCell(); cell.Value = item.Name; cell.Tag = item.InstanceId; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Atk", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Mag", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Mnd", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Def", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Res", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Acc", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Eva", itemHasSynergy); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = item.StatWithSynergy("Spd", itemHasSynergy); row.Cells.Add(cell); if (itemEquippedElsewhere) { row.DefaultCellStyle.BackColor = System.Drawing.Color.Red; } else if (itemHasSynergy) { row.DefaultCellStyle.BackColor = System.Drawing.Color.Aqua; } else { row.DefaultCellStyle.BackColor = System.Drawing.Color.Empty; } dataGridViewEquipment.Rows.Add(row); } if (dataGridViewEquipment.SortedColumn != null) { ListSortDirection sortDirection = dataGridViewEquipment.SortOrder == SortOrder.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending; dataGridViewEquipment.Sort(dataGridViewEquipment.SortedColumn, sortDirection); } }
private void AddItem(DataRow data) { DataGridViewRow row = new DataGridViewRow(); row.Tag = data; DataGridViewCheckBoxCell chkBoxCell = new DataGridViewCheckBoxCell(); chkBoxCell.Value = false; chkBoxCell.Tag = data["id"]; row.Cells.Add(chkBoxCell); DataGridViewTextBoxCell txtNumber = new DataGridViewTextBoxCell(); txtNumber.Value = Convert.ToInt32(dataGridView1.Rows.Count + 1); row.Cells.Add(txtNumber); DataGridViewTextBoxCell txtBox1 = new DataGridViewTextBoxCell(); txtBox1.Value = Convert.ToInt32(data["id"]); //txtBox1.Tag = question.Id.ToString(); txtBox1.ToolTipText = "ID=" + data["id"].ToString(); txtBox1.Tag = data["id"]; row.Cells.Add(txtBox1); txtBox1.ReadOnly = true; DataGridViewTextBoxCell txtBox2 = new DataGridViewTextBoxCell(); txtBox2.Value = data["tittle"]; txtBox2.ToolTipText = data["tittle"].ToString(); row.Cells.Add(txtBox2); txtBox2.ReadOnly = true; //这个类别不正确 DataGridViewTextBoxCell txtBox3 = new DataGridViewTextBoxCell(); int classfication = Convert.ToInt32(data["classification"]); if (classfication == 0) { txtBox3.Value = "未分类"; } else { txtBox3.Value = Question._ModelClassificationInfo[classfication]; } txtBox3.ToolTipText = "题目类别"; row.Cells.Add((DataGridViewTextBoxCell)txtBox3); txtBox3.ReadOnly = true; int type = Convert.ToInt32(data["type"]); DataGridViewTextBoxCell txtBox4 = new DataGridViewTextBoxCell(); txtBox4.Value = Question._TypeInfo[type]; if (type == 1) { txtBox4.ToolTipText = "题目类型"; } else { txtBox4.ToolTipText = "题目类型"; } row.Cells.Add((DataGridViewTextBoxCell)txtBox4); txtBox4.Tag = type; txtBox4.ReadOnly = true; DataGridViewTextBoxCell txtBox5 = new DataGridViewTextBoxCell(); if (string.IsNullOrEmpty(data["chapter_name"].ToString())) { txtBox5.Value = "未分类"; txtBox5.ToolTipText = "未分类"; } else { txtBox5.Value = data["chapter_name"].ToString(); txtBox5.ToolTipText = data["chapter_name"].ToString(); } row.Cells.Add((DataGridViewTextBoxCell)txtBox5); txtBox5.ReadOnly = true; DataGridViewTextBoxCell txtBox6 = new DataGridViewTextBoxCell(); if (string.IsNullOrEmpty(data["skill_name"].ToString())) { txtBox6.Value = "未分类"; txtBox6.ToolTipText = "未分类"; } else { txtBox6.Value = data["skill_name"]; txtBox6.ToolTipText = data["skill_name"].ToString(); } row.Cells.Add((DataGridViewTextBoxCell)txtBox6); txtBox6.ReadOnly = true; DataGridViewTextBoxCell txtBox7 = new DataGridViewTextBoxCell(); // txtBox6.Tag = question.Skill; if (string.IsNullOrEmpty(data["bank_name"].ToString())) { txtBox7.Value = "未分类"; txtBox7.ToolTipText = "未分类"; } else { txtBox7.Value = data["bank_name"]; txtBox7.ToolTipText = data["bank_name"].ToString(); } row.Cells.Add((DataGridViewTextBoxCell)txtBox7); txtBox7.ReadOnly = true; DataGridViewButtonCell button = new DataGridViewButtonCell(); button.Value = "编辑"; row.Cells.Add(button); button = new DataGridViewButtonCell(); button.Value = "删除"; row.Cells.Add(button); row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows.Add(row); }
private void BindData(string filePath) { // Read content from csv file string[] lines = File.ReadAllLines(filePath); columnTypes = new Dictionary <int, string>(); rowPriceDictionary = new Dictionary <int, double>(); myDataGridView.Columns.Clear(); if (lines.Length > 0) { //Obtaining column headers string headerLine = lines[0]; string[] headerLabels = headerLine.Split(';'); int columnIndex = 0; //Custom ID //Assigning headers to columns. foreach (string headerWord in headerLabels) { string[] headerList = { "Title", "Author", "Year", "Price" }; priceIndex = Array.IndexOf(headerList, "Price"); //Index required for color gradient calculations if (headerList.Contains(headerWord)) { DataGridViewTextBoxColumn textBoxColumn = new DataGridViewTextBoxColumn(); textBoxColumn.HeaderText = headerWord; textBoxColumn.Name = headerWord; textBoxColumn.ReadOnly = true; textBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; myDataGridView.Columns.Add(textBoxColumn); columnTypes.Add(columnIndex, "textbox"); } else { switch (headerWord) { case "In Stock": DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn(); checkBoxColumn.HeaderText = "In Stock"; checkBoxColumn.Name = "In_Stock"; checkBoxColumn.ReadOnly = true; checkBoxColumn.FlatStyle = FlatStyle.Standard; checkBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; myDataGridView.Columns.Add(checkBoxColumn); columnTypes.Add(columnIndex, "checkbox"); break; case "Binding": DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn(); comboBoxColumn.HeaderText = "Binding"; comboBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; comboBoxColumn.ReadOnly = false; columnTypes.Add(columnIndex, "combobox"); myDataGridView.Columns.Add(comboBoxColumn); break; case "Description": DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn(); buttonColumn.HeaderText = "Description"; buttonColumn.Name = "Description"; buttonColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; buttonColumn.ReadOnly = true; myDataGridView.Columns.Add(buttonColumn); columnTypes.Add(columnIndex, "button"); break; } } columnIndex++; } //Iterating through rows for (int i = 1; i < lines.Length; i++) { //Obtaining string in cells of the row string[] dataWords = lines[i].Split(';'); //Creating rows DataGridViewRow row = new DataGridViewRow(); //Populating row data for (columnIndex = 0; columnIndex < headerLabels.Length; columnIndex++) { string dataWord = dataWords[columnIndex]; string[] list = { "Title", "Author", "Year", "Price" }; switch (columnTypes[columnIndex]) { case "button": DataGridViewButtonCell buttonCell = new DataGridViewButtonCell { Value = "Click" }; buttonCell.Tag = dataWord.Trim('"'); row.Cells.Add(buttonCell); break; case "checkbox": DataGridViewCheckBoxCell checkBoxCell = new DataGridViewCheckBoxCell(); if (dataWord == "yes") { checkBoxCell.Value = true; } else { checkBoxCell.Value = false; } row.Cells.Add(checkBoxCell); break; case "combobox": DataGridViewComboBoxCell comboBoxCell = new DataGridViewComboBoxCell(); comboBoxCell.Items.Add("Unknown"); comboBoxCell.Items.Add("Paperback"); comboBoxCell.Items.Add("Hardcover"); comboBoxCell.Items.Add("Coalwood"); comboBoxCell.Value = dataWord; row.Cells.Add(comboBoxCell); break; default: DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell { Value = dataWord }; row.Cells.Add(textBoxCell); break; } } myDataGridView.Rows.Add(row); //Add the prices into a lookup dictionary double price = double.Parse(dataWords[priceIndex].Replace(',', '.')); if (price > maxPrice) { maxPrice = price; } if (price < minPrice) { minPrice = price; } rowPriceDictionary.Add(i - 1, price); } //Highlighting price text colour SetPriceColors(); //Highlighting books not in stock HighlightOutOfStock(); } else { MessageBox.Show("Please select a valid CSV file", "GUI Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public virtual DataGridViewSpectrumRow CreateSpectrumRow(ISpectrum spectrum) { DataGridViewSpectrumRow spectrumRow = new DataGridViewSpectrumRow(spectrum); DataGridViewTextBoxCell spectrumcell = new DataGridViewTextBoxCell(); spectrumcell.Value = spectrum.Name; spectrumcell.Style.BackColor = System.Drawing.SystemColors.Control; //spectrumcell.ReadOnly = true; spectrumRow.Cells.Add(spectrumcell); //spectrumcell = new DataGridViewTextBoxCell(); DataGridViewParameterCell keyValueCell = CreateParameterCell(spectrum.Parameters[0].Components[0]["key value"]); keyValueCell.Style.BackColor = System.Drawing.SystemColors.Control; spectrumRow.Cells.Add(keyValueCell); if (FixedColCount == 3) { //dodatkowa kolumna z nazwa contenera spectrumcell = new DataGridViewTextBoxCell(); spectrumcell.Value = spectrum.Container.Name; spectrumcell.Style.BackColor = System.Drawing.SystemColors.Control; spectrumRow.Cells.Add(spectrumcell); } spectrumcell = new DataGridViewCustomValueCell(delegate(ISpectrum s) { if (double.IsInfinity(s.Fit) || double.IsNaN(s.Fit)) { return(" "); } else { return(s.Fit.ToString("F4")); } }); spectrumcell.Style.BackColor = System.Drawing.SystemColors.Control; spectrumRow.Cells.Add(spectrumcell); //spectrumcell.ReadOnly = true; foreach (IComponent component in spectrum.Parameters[groupDefinition.name].Components) { foreach (IParameter parameter in component) { //if (!parameter.Definition.Visible) continue; spectrumRow.Cells.Add(CreateParameterCell(parameter)); } } foreach (IParameter parameter in spectrum.Parameters[groupDefinition.name].GroupUniqueParameters) { spectrumRow.Cells.Add(CreateParameterCell(parameter)); } if (HasGraphicAdjustment) { DataGridViewButtonCell adjustButton = new DataGridViewButtonCell(); adjustButton.Value = "adjust..."; adjustButton.Style.Font = new Font("Arial", gridView.Font.Size); adjustButton.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; adjustButton.Style.ForeColor = System.Drawing.Color.Black; adjustButton.Style.SelectionForeColor = adjustButton.Style.ForeColor; adjustButton.Style.BackColor = System.Drawing.SystemColors.ButtonFace; adjustButton.Style.SelectionBackColor = adjustButton.Style.BackColor; adjustButton.FlatStyle = FlatStyle.Popup; adjustButton.ToolTipText = ""; spectrumRow.Cells.Add(adjustButton); spectrumcell = new DataGridViewCustomValueCell(delegate(ISpectrum s) { return(String.Format("{0:F3} mln", s.Statistic / 1e6)); }); spectrumcell.Style.BackColor = System.Drawing.SystemColors.Control; spectrumRow.Cells.Add(spectrumcell); } return(spectrumRow); }
private void lstWeights_SelectedIndexChanged(object sender, EventArgs e) { btnRemoveWeight.Enabled = lstWeights.SelectedIndices.Count == 1; if (lstWeights.SelectedIndices.Count == 1) { IGraphWeight weight = ((WeightListViewItem)lstWeights.SelectedItems[0]).GraphWeight; propsWeight.SelectedObject = weight; gridFcs.Rows.Clear(); foreach (IFeatureClass fc in _selected.EdgeFeatureclasses) { int fcId = _database.GetFeatureClassID(fc.Name); DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell idCell = new DataGridViewTextBoxCell(); idCell.Value = fcId; row.Cells.Add(idCell); DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell(); nameCell.Value = fc.Name; row.Cells.Add(nameCell); DataGridViewComboBoxCell fieldCell = new DataGridViewComboBoxCell(); fieldCell.Items.Add("<none>"); foreach (IField field in fc.Fields) { switch (field.type) { case FieldType.integer: case FieldType.smallinteger: case FieldType.biginteger: case FieldType.Float: case FieldType.Double: fieldCell.Items.Add(field.name); break; } } IGraphWeightFeatureClass gwfc = weight.FeatureClasses[fcId]; if (gwfc == null) { fieldCell.Value = "<none>"; } else { fieldCell.Value = gwfc.FieldName; } row.Cells.Add(fieldCell); DataGridViewComboBoxCell calcCell = new DataGridViewComboBoxCell(); calcCell.Items.Add("<none>"); foreach (ISimpleNumberCalculation calc in _calculators) { calcCell.Items.Add(calc.Name); } if (gwfc == null || gwfc.SimpleNumberCalculation == null) { calcCell.Value = "<none>"; } else { calcCell.Value = gwfc.SimpleNumberCalculation.Name; } row.Cells.Add(calcCell); DataGridViewButtonCell calcPropCell = new DataGridViewButtonCell(); calcPropCell.Value = "..."; row.Cells.Add(calcPropCell); gridFcs.Rows.Add(row); } } }
private void llenarDGVAnalisis() { DGV_Análisis.ReadOnly = true; DGV_Análisis.Rows.Clear(); DGV_Análisis.Columns[4].Width = 10; DGV_Análisis.Columns[5].DefaultCellStyle.Padding = new Padding(11); //DGV_Análisis.ColumnCount = 4; //int j = 0; for (int i = 0; i < plantilla.listaRestricciones.Count; i++) { IRestriccion restriccion = plantilla.listaRestricciones[i]; Structure estructura = estructuraCorrespondiente(restriccion.estructura.nombre); DGV_Análisis.Rows.Add(); DGV_Análisis.Rows[i].Cells[0].Value = Estructura.nombreEnDiccionario(restriccion.estructura); //DGV_Análisis.Rows[i].Cells[0].Value = restriccion.estructura.nombre; DGV_Análisis.Rows[i].Cells[1].Value = restriccion.metrica(); string menorOmayor; if (restriccion.esMenorQue) { menorOmayor = "<"; } else { menorOmayor = ">"; } string valorEsperadoString = menorOmayor + restriccion.valorEsperado + restriccion.unidadValor; if (!Double.IsNaN(restriccion.valorTolerado)) { valorEsperadoString += " (" + restriccion.valorTolerado + restriccion.unidadValor + ")"; } DGV_Análisis.Rows[i].Cells[4].Value = valorEsperadoString; DGV_Análisis.Rows[i].Cells[5].Value = restriccion.nota; if (estructura != null) { DGV_Análisis.Rows[i].Cells[2].Value = Math.Round(estructura.Volume, 2).ToString(); restriccion.analizarPlanEstructura(planSeleccionado(), estructura); if (restriccion.chequearSamplingCoverage(planSeleccionado(), estructura)) { MessageBox.Show("La estructura " + estructura.Id + " no tiene el suficiente Sampling Coverage.\nNo se puede realizar el análisis"); } else { DGV_Análisis.Rows[i].Cells[3].Value = restriccion.valorMedido + restriccion.unidadValor; colorCelda(DGV_Análisis.Rows[i].Cells[3], restriccion.cumple()); } if (restriccion.GetType() == typeof(RestriccionDosisMax)) { DataGridViewButtonCell bt = (DataGridViewButtonCell)DGV_Análisis.Rows[i].Cells[6]; bt.FlatStyle = FlatStyle.System; bt.Style.BackColor = System.Drawing.Color.LightGray; bt.Style.ForeColor = System.Drawing.Color.Black; bt.Style.SelectionBackColor = System.Drawing.Color.LightGray; bt.Style.SelectionForeColor = System.Drawing.Color.Black; bt.Value = RestriccionDosisMax.volumenDosisMaxima.ToString(); DGV_Análisis.Rows[i].Cells[6].Style.Padding = new Padding(0, 0, 0, 1); } } } DGV_Análisis.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; }
private void PaintTable() { _grid.Rows.Clear(); for (int i = 0; i < _parameters.Count; i++) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells[0].Value = _parameters[i].Name; if (_parameters[i].Type == StrategyParameterType.Bool) { DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); cell.Items.Add("False"); cell.Items.Add("True"); cell.Value = ((StrategyParameterBool)_parameters[i]).ValueBool.ToString(); row.Cells.Add(cell); } else if (_parameters[i].Type == StrategyParameterType.String) { StrategyParameterString param = (StrategyParameterString)_parameters[i]; if (param.ValuesString.Count > 1) { DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); for (int i2 = 0; i2 < param.ValuesString.Count; i2++) { cell.Items.Add(param.ValuesString[i2]); } cell.Value = param.ValueString; row.Cells.Add(cell); } else if (param.ValuesString.Count == 1) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = param.ValueString; row.Cells.Add(cell); } } else if (_parameters[i].Type == StrategyParameterType.Int) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); StrategyParameterInt param = (StrategyParameterInt)_parameters[i]; cell.Value = param.ValueInt.ToString(); row.Cells.Add(cell); } else if (_parameters[i].Type == StrategyParameterType.Decimal) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); StrategyParameterDecimal param = (StrategyParameterDecimal)_parameters[i]; cell.Value = param.ValueDecimal.ToString(); row.Cells.Add(cell); } else if (_parameters[i].Type == StrategyParameterType.TimeOfDay) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); StrategyParameterTimeOfDay param = (StrategyParameterTimeOfDay)_parameters[i]; cell.Value = param.Value.ToString(); row.Cells.Add(cell); } else if (_parameters[i].Type == StrategyParameterType.Button) { DataGridViewButtonCell cell = new DataGridViewButtonCell(); row.Cells[0].Value = ""; cell.Value = _parameters[i].Name; // StrategyParameterButton param = (StrategyParameterButton)_parameters[i]; row.Cells.Add(cell); } else if (_parameters[i].Type == StrategyParameterType.Label) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); StrategyParameterLabel param = (StrategyParameterLabel)_parameters[i]; if (param.RowHeight == 0) { param.RowHeight = 25; } row.Cells[0].Value = param.Label; row.Height = param.RowHeight; row.Cells[0].Style.Font = new System.Drawing.Font("Areal", param.TextHeight); row.Cells[0].Style.ForeColor = param.Color; row.Cells.Add(cell); } _grid.Rows.Add(row); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } DataGridViewButtonCell cell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewButtonCell; if (cell != null) { if (e.ColumnIndex == 2)/*TMS*/ { string tms = Convert.ToString(cell.Value); if (!string.IsNullOrEmpty(tms)) { string[] tmsTab = tms.Split('-'); if (tmsTab.Length == 2) { string client = tmsTab[0]; string numb = tmsTab[1]; string finalLnk = string.Format(TMS_LINK, client, numb); Process.Start("chrome.exe", finalLnk); } } } else if (e.ColumnIndex == 3) /* TMS ACTION HIST */ { DataGridViewButtonCell tmsTaskCell = dataGridView1.Rows[e.RowIndex].Cells[2] as DataGridViewButtonCell; string tms = Convert.ToString(tmsTaskCell.Value); if (!string.IsNullOrEmpty(tms)) { string[] tmsTab = tms.Split('-'); if (tmsTab.Length == 2) { string client = tmsTab[0]; string numb = tmsTab[1]; TMSTaskSynchronizer tmsTaskSynchronizer = TMSTaskSynchronizer.GetInstance(client, this); DataTable tmsActions = tmsTaskSynchronizer.GetActionsForTMS(numb); TMSActionsForm form = new TMSActionsForm(); form.WriteToGrid(tmsActions); form.ShowDialog(); } } } else if (e.ColumnIndex == 4) /* RM LINK*/ { string rmId = Convert.ToString(cell.Value); if (!string.IsNullOrEmpty(rmId)) { string finalLnk = string.Format(RM_LINK, rmId); Process.Start("chrome.exe", finalLnk); } } else if (e.ColumnIndex == 5) /* RM ACTION HIST */ { } else if (e.ColumnIndex == 8) { DataGridViewTextBoxCell assignedToCell = dataGridView1.Rows[e.RowIndex].Cells[4] as DataGridViewTextBoxCell; DataGridViewButtonCell rmIssueNum = dataGridView1.Rows[e.RowIndex].Cells[3] as DataGridViewButtonCell; if (assignedToCell != null && rmIssueNum != null) { string assignedInTMS = Convert.ToString(assignedToCell.Value); string rmId = Convert.ToString(rmIssueNum.Value); if (!string.IsNullOrEmpty(assignedInTMS) && !string.IsNullOrEmpty(rmId)) { NameValueCollection parameters = new NameValueCollection { { RedmineKeys.INCLUDE, $"{RedmineKeys.CHANGE_SETS},{RedmineKeys.JOURNALS},{RedmineKeys.NOTES}" } }; Issue rmIssue = RMManegerService.RMManager.GetObject <Issue>(rmId, parameters); if (rmIssue != null) { } //var newIssue = new Issue { Subject = subject, Project = p, Description = details }; //MManegerService.RMManager.CreateObject(newIssue); // fixture.RedmineManager.UpdateObject(UPDATED_ISSUE_ID, issue); switch (assignedInTMS) { case "N/GENEBUG": break; } } } //string assignedInTMS = dataGridView1.Rows[e.RowIndex].Cells[4]; } } }
internal void AddJobsInfo(ICollection <JobItem> jobItemList, ICollection <JobItem> exemptCompaniesJobItems) { if ((jobItemList == null) || (jobItemList.Count == 0)) { labelStatus.Text = "None found"; return; } labelStatus.Text = string.Empty; foreach (JobItem jobItem in jobItemList) { DataGridViewRow dataGridViewRow = new DataGridViewRow(); DataGridViewTextBoxCell dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.title; dataGridViewRow.Cells.Add(dataGridViewTextBox); dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.company; dataGridViewRow.Cells.Add(dataGridViewTextBox); dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.location; if (jobItem.location.Contains("San Francisco")) { dataGridViewTextBox.Style.ForeColor = System.Drawing.Color.ForestGreen; } dataGridViewRow.Cells.Add(dataGridViewTextBox); DataGridViewButtonCell c = new DataGridViewButtonCell(); string careerLink = string.Format("https://www.google.com/search?q=careers+at+{0}", jobItem.company); c.Tag = careerLink; c.Value = "Career"; dataGridViewRow.Cells.Add(c); DataGridViewButtonCell l = new DataGridViewButtonCell(); l.Tag = jobItem; l.Value = "LinkedIn"; dataGridViewRow.Cells.Add(l); if (jobItem.JobId == 0) { l.Value = "?"; } dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.Submitted; dataGridViewRow.Cells.Add(dataGridViewTextBox); if (jobItem.Submitted.Equals("Unsubmitted")) { dataGridViewTextBox.Style.ForeColor = System.Drawing.Color.DarkOliveGreen; dataGridViewUnSubmitted.Rows.Add(dataGridViewRow); } else { dataGridViewTextBox.Style.ForeColor = System.Drawing.Color.OrangeRed; dataGridViewSubmitted.Rows.Add(dataGridViewRow); } // } //ExemptCompaniesJobItems foreach (JobItem jobItem in exemptCompaniesJobItems) { DataGridViewRow dataGridViewRow = new DataGridViewRow(); DataGridViewTextBoxCell dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.title; dataGridViewRow.Cells.Add(dataGridViewTextBox); dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.company; dataGridViewRow.Cells.Add(dataGridViewTextBox); dataGridViewTextBox = new DataGridViewTextBoxCell(); dataGridViewTextBox.Value = jobItem.location; if (jobItem.location.Contains("San Francisco")) { dataGridViewTextBox.Style.ForeColor = System.Drawing.Color.ForestGreen; } dataGridViewRow.Cells.Add(dataGridViewTextBox); dataGridViewExemptJobsByCompany.Rows.Add(dataGridViewRow); } // }
/// <summary> /// This method will create a date drop downin the specified cell. /// </summary> public void CreateButtonInCell(DataGridViewCell Cell) { DataGridViewButtonCell Button = new DataGridViewButtonCell(); ReplaceCell(Cell, Button); }
void dd_FormClosing(object sender, FormClosingEventArgs e) { /* dtclmnid; dtclmnTitle; dtclmnAmount; dtclmnNote;*/ //_currentinvoiceitems.Add( invoiceitem newrow = new invoiceitem(); InvoiceControlAccompanyStockAdd ctrl = (InvoiceControlAccompanyStockAdd)sender; if (string.IsNullOrEmpty(ctrl.Title) || string.IsNullOrEmpty(ctrl.Amount)) return; int i; i = dataGridView1.Rows.Add( new DataGridViewRow()); DataGridViewCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; newrow.title = ctrl.Title; dataGridView1.Rows[i].Cells["dtclmnTitle"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Note; newrow.note = ctrl.Note; dataGridView1.Rows[i].Cells["dtclmnNote"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Amount; newrow.amount = Convert.ToInt32(ctrl.Amount); dataGridView1.Rows[i].Cells["dtclmnAmount"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = i+1; newrow.num = (i + 1).ToString(); dataGridView1.Rows[i].Cells["dtclmnid"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Type; newrow.type = ctrl._Type; dataGridView1.Rows[i].Cells["dttype"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl._Typeid; newrow.typeid = ctrl._Typeid; dataGridView1.Rows[i].Cells["dttypeid"] = cell1; DataGridViewButtonCell cell2 = new DataGridViewButtonCell(); cell2.Value = "מחיקה"; dataGridView1.Rows[i].Cells["dtbttndelet"] = cell2; _currentinvoiceitems.Add(newrow); /* cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; dataGridView1.Rows[i].Cells["Amount"] = cell1; cell1 = new DataGridViewTextBoxCell(); cell1.Value = ctrl.Title; dataGridView1.Rows[i].Cells["Title"] = cell1;*/ }
public void UIAType_SelectionChangeCommitted(object sender, EventArgs e) { ComboBox selectedAction = AutomationTypeControl; if (selectedAction == null) { return; } DataGridView actionParameterView = ActionParametersGridViewHelper; actionParameterView.Refresh(); DataTable actionParameters = v_UIAActionParameters; if (sender != null) { actionParameters.Rows.Clear(); } switch (selectedAction.SelectedItem) { case "Click Element": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } var mouseClickBox = new DataGridViewComboBoxCell(); mouseClickBox.Items.Add("Left Click"); mouseClickBox.Items.Add("Middle Click"); mouseClickBox.Items.Add("Right Click"); mouseClickBox.Items.Add("Left Down"); mouseClickBox.Items.Add("Middle Down"); mouseClickBox.Items.Add("Right Down"); mouseClickBox.Items.Add("Left Up"); mouseClickBox.Items.Add("Middle Up"); mouseClickBox.Items.Add("Right Up"); mouseClickBox.Items.Add("Double Left Click"); if (sender != null) { actionParameters.Rows.Add("Click Type", ""); actionParameters.Rows.Add("X Adjustment", 0); actionParameters.Rows.Add("Y Adjustment", 0); } actionParameterView.Rows[0].Cells[1] = mouseClickBox; break; case "Set Text": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Text To Set"); actionParameters.Rows.Add("Clear Element Before Setting Text"); actionParameters.Rows.Add("Encrypted Text"); actionParameters.Rows.Add("Optional - Click to Encrypt 'Text To Set'"); DataGridViewComboBoxCell encryptedBox = new DataGridViewComboBoxCell(); encryptedBox.Items.Add("Not Encrypted"); encryptedBox.Items.Add("Encrypted"); actionParameterView.Rows[2].Cells[1] = encryptedBox; actionParameterView.Rows[2].Cells[1].Value = "Not Encrypted"; var buttonCell = new DataGridViewButtonCell(); actionParameterView.Rows[3].Cells[1] = buttonCell; actionParameterView.Rows[3].Cells[1].Value = "Encrypt Text"; actionParameterView.CellContentClick += ElementsGridViewHelper_CellContentClick; } DataGridViewComboBoxCell comparisonComboBox = new DataGridViewComboBoxCell(); comparisonComboBox.Items.Add("Yes"); comparisonComboBox.Items.Add("No"); //assign cell as a combobox if (sender != null) { actionParameterView.Rows[1].Cells[1].Value = "No"; } actionParameterView.Rows[1].Cells[1] = comparisonComboBox; break; case "Set Secure Text": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Secure String Variable"); actionParameters.Rows.Add("Clear Element Before Setting Text"); } DataGridViewComboBoxCell _comparisonComboBox = new DataGridViewComboBoxCell(); _comparisonComboBox.Items.Add("Yes"); _comparisonComboBox.Items.Add("No"); //assign cell as a combobox if (sender != null) { actionParameterView.Rows[1].Cells[1].Value = "No"; } actionParameterView.Rows[1].Cells[1] = _comparisonComboBox; break; case "Get Text": case "Check If Element Exists": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Apply To Variable", ""); } break; case "Clear Element": foreach (var ctrl in ElementParameterControls) { ctrl.Hide(); } break; case "Wait For Element To Exist": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Timeout (Seconds)"); } break; case "Get Value From Element": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } var parameterName = new DataGridViewComboBoxCell(); parameterName.Items.Add("AcceleratorKey"); parameterName.Items.Add("AccessKey"); parameterName.Items.Add("AutomationId"); parameterName.Items.Add("ClassName"); parameterName.Items.Add("FrameworkId"); parameterName.Items.Add("HasKeyboardFocus"); parameterName.Items.Add("HelpText"); parameterName.Items.Add("IsContentElement"); parameterName.Items.Add("IsControlElement"); parameterName.Items.Add("IsEnabled"); parameterName.Items.Add("IsKeyboardFocusable"); parameterName.Items.Add("IsOffscreen"); parameterName.Items.Add("IsPassword"); parameterName.Items.Add("IsRequiredForForm"); parameterName.Items.Add("ItemStatus"); parameterName.Items.Add("ItemType"); parameterName.Items.Add("LocalizedControlType"); parameterName.Items.Add("Name"); parameterName.Items.Add("NativeWindowHandle"); parameterName.Items.Add("ProcessID"); if (sender != null) { actionParameters.Rows.Add("Get Value From", ""); actionParameters.Rows.Add("Apply To Variable", ""); actionParameterView.Refresh(); try { actionParameterView.Rows[0].Cells[1] = parameterName; } catch (Exception ex) { MessageBox.Show("Unable to select first row, second cell to apply '" + parameterName + "': " + ex.ToString()); } } break; default: break; } actionParameterView.Refresh(); }
private void AddItem(Question question) { if (!string.IsNullOrEmpty(textBoxFilterTittle.Text)) { if (question.Tittle.IndexOf(textBoxFilterTittle.Text) == -1) { return; } } if (!string.IsNullOrEmpty(textBoxFilterOptions.Text)) { bool isFind = false; foreach (var info in question.Options) { if (info.IndexOf(textBoxFilterOptions.Text) != -1) { isFind = true; } } if (isFind == false) { return; } } DataGridViewRow row = new DataGridViewRow(); DataGridViewCheckBoxCell chkBoxCell = new DataGridViewCheckBoxCell(); chkBoxCell.Value = false; chkBoxCell.Tag = question; row.Cells.Add(chkBoxCell); DataGridViewTextBoxCell txtBox1 = new DataGridViewTextBoxCell(); txtBox1.Value = Convert.ToInt32(dataGridView1.Rows.Count + 1); //txtBox1.Tag = question.Id.ToString(); txtBox1.ToolTipText = "ID=" + question.Id.ToString(); row.Cells.Add(txtBox1); txtBox1.ReadOnly = true; DataGridViewTextBoxCell txtBox2 = new DataGridViewTextBoxCell(); txtBox2.Value = question.Tittle; txtBox2.ToolTipText = question.Tittle; row.Cells.Add(txtBox2); txtBox2.ReadOnly = true; //这个类别不正确 DataGridViewTextBoxCell txtBox3 = new DataGridViewTextBoxCell(); if (question.Classification == 0) { txtBox3.Value = "未分类"; } else { txtBox3.Value = Question._ModelClassificationInfo[question.Classification]; } txtBox3.ToolTipText = "题目类别"; row.Cells.Add((DataGridViewTextBoxCell)txtBox3); txtBox3.ReadOnly = true; //txtBox3.Tag = question.Type; DataGridViewTextBoxCell txtBox4 = new DataGridViewTextBoxCell(); txtBox4.Value = Question._TypeInfo[question.Type]; if (question.Type == 1) { txtBox4.ToolTipText = "题目类型"; } else { string questionOptions = ""; for (int i = 1; i <= question.Options.Count; i++) { var option = question.Options[i - 1]; questionOptions += i.ToString() + "." + option + " "; } txtBox4.ToolTipText = questionOptions; } row.Cells.Add((DataGridViewTextBoxCell)txtBox4); //txtBox4.Tag = question.Type; txtBox4.ReadOnly = true; DataGridViewTextBoxCell txtBox5 = new DataGridViewTextBoxCell(); ChapterInfo model = new ChapterInfo(); ModelManager.m_DicMoudleList.TryGetValue(question.Module, out model); if (model == null) { txtBox5.Value = "未分类"; txtBox5.ToolTipText = "未分类"; } else { txtBox5.Value = model.Name; txtBox5.ToolTipText = model.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox5); txtBox5.ReadOnly = true; DataGridViewTextBoxCell txtBox6 = new DataGridViewTextBoxCell(); // txtBox6.Tag = question.Skill; ChapterInfo modelSkill = null; ModelManager.m_DicSkillList.TryGetValue(question.Skill, out modelSkill); if (modelSkill == null) { txtBox6.Value = "未分类"; txtBox6.ToolTipText = "未分类"; } else { txtBox6.Value = modelSkill.Name; txtBox6.ToolTipText = modelSkill.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox6); txtBox6.ReadOnly = true; DataGridViewTextBoxCell txtBox7 = new DataGridViewTextBoxCell(); // txtBox6.Tag = question.Skill; ChapterInfo modelBank = null; ModelManager.m_DicBankList.TryGetValue(question.BankId, out modelBank); if (modelBank == null) { txtBox7.Value = "未分类"; txtBox7.ToolTipText = "未分类"; } else { txtBox7.Value = modelBank.Name; txtBox7.ToolTipText = modelBank.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox7); txtBox7.ReadOnly = true; DataGridViewButtonCell button = new DataGridViewButtonCell(); button.Value = "编辑"; row.Cells.Add(button); button = new DataGridViewButtonCell(); button.Value = "删除"; row.Cells.Add(button); row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows.Add(row); }
private void cmbTable_SelectedIndexChanged(object sender, EventArgs e) { tblRelation.Rows.Clear(); //requesting all the attributes of the table along with the information String attrib = server.GetAllAttributes(cmbTable.SelectedItem.ToString()); int i = 0; string[] attributes = attrib.Split('|'); attributes = attributes.Take(attributes.Count() - 1).ToArray(); string[][] attribute = new string[attributes.Length][]; //get each attribute's properties of the selected table foreach (string atr in attributes) { attribute[i] = atr.Split('^'); i++; } mandetory_flag = new int[i - 1]; unique_flag = new int[i - 1]; //loop through the number of attributes for (int step = 0; step < attributes.Length - 1; step++) { Object[] tmp_ = new Object [10]; int index = 0; //ading each attribute's information to the table foreach (string atr in attribute[step]) { tmp_[index] = atr; index++; } if (tmp_[3].ToString().Equals("NO")) //identifying the mandatory fields { tmp_[3] = true; mandetory_flag[step] = 0; } else { tmp_[3] = false; mandetory_flag[step] = 1; } if (tmp_[4].ToString().Equals("UNI")) //identifying the unique fields { tmp_[4] = false; tmp_[5] = true; unique_flag[step] = 0; } else if (tmp_[4].ToString().Equals("PRI")) //identifying the primary keys { tmp_[4] = true; tmp_[3] = true; tmp_[5] = false; unique_flag[step] = 1; } else { unique_flag[step] = 1; tmp_[4] = false; tmp_[5] = false; tmp_[7] = true; } tblRelation.Rows.Add(tmp_); //adding a row to the table } foreignRefs = new String[tblRelation.RowCount][][]; for (int index = 0; i < tblRelation.RowCount; i++) { DataGridViewButtonCell btn = (DataGridViewButtonCell)tblRelation.Rows[index].Cells[8]; btn.Value = "Show References"; } refTbl = new String[tblRelation.RowCount]; sign = new string[tblRelation.RowCount]; refCount = 0; }
private void mgProyectos_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex >= 0 && this.mgProyectos.Columns[e.ColumnIndex].Name == "Editar" && e.RowIndex >= 0) { e.Paint(e.CellBounds, DataGridViewPaintParts.All); DataGridViewButtonCell cellButtonEditar = this.mgProyectos.Rows[e.RowIndex].Cells["Editar"] as DataGridViewButtonCell; Icon icoEditar = Properties.Resources.editar; e.Graphics.DrawIcon(icoEditar, e.CellBounds.Left + 4, e.CellBounds.Top + 4); this.mgProyectos.Rows[e.RowIndex].Height = icoEditar.Height + 8; this.mgProyectos.Columns[e.ColumnIndex].Width = icoEditar.Width + 8; DataGridViewCell cell = this.mgProyectos.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.ToolTipText = "Editar"; e.Handled = true; } if (e.ColumnIndex >= 0 && this.mgProyectos.Columns[e.ColumnIndex].Name == "Ver" && e.RowIndex >= 0) { e.Paint(e.CellBounds, DataGridViewPaintParts.All); DataGridViewButtonCell cellButtonVer = this.mgProyectos.Rows[e.RowIndex].Cells["Ver"] as DataGridViewButtonCell; Icon icoVer = Properties.Resources.ver; e.Graphics.DrawIcon(icoVer, e.CellBounds.Left + 4, e.CellBounds.Top + 4); this.mgProyectos.Rows[e.RowIndex].Height = icoVer.Height + 8; this.mgProyectos.Columns[e.ColumnIndex].Width = icoVer.Width + 8; DataGridViewCell cell = this.mgProyectos.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.ToolTipText = "Ver"; e.Handled = true; } if (e.ColumnIndex >= 0 && this.mgProyectos.Columns[e.ColumnIndex].Name == "Horas Trabajadas" && e.RowIndex >= 0) { e.Paint(e.CellBounds, DataGridViewPaintParts.All); DataGridViewButtonCell cellButtonVer = this.mgProyectos.Rows[e.RowIndex].Cells["Horas Trabajadas"] as DataGridViewButtonCell; Icon icoHoras = Properties.Resources.reloj; e.Graphics.DrawIcon(icoHoras, e.CellBounds.Left + 4, e.CellBounds.Top + 4); this.mgProyectos.Rows[e.RowIndex].Height = icoHoras.Height + 8; this.mgProyectos.Columns[e.ColumnIndex].Width = icoHoras.Width + 8; DataGridViewCell cell = this.mgProyectos.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.ToolTipText = "Horas Trabajadas"; e.Handled = true; } if (e.ColumnIndex >= 0 && this.mgProyectos.Columns[e.ColumnIndex].Name == "Informe Semanal" && e.RowIndex >= 0) { e.Paint(e.CellBounds, DataGridViewPaintParts.All); DataGridViewButtonCell cellButtonVer = this.mgProyectos.Rows[e.RowIndex].Cells["Informe Semanal"] as DataGridViewButtonCell; Icon icoCalendar = Properties.Resources.calendar; e.Graphics.DrawIcon(icoCalendar, e.CellBounds.Left + 4, e.CellBounds.Top + 4); this.mgProyectos.Rows[e.RowIndex].Height = icoCalendar.Height + 8; this.mgProyectos.Columns[e.ColumnIndex].Width = icoCalendar.Width + 8; DataGridViewCell cell = this.mgProyectos.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.ToolTipText = "Informe Semanal Horas Overbudget"; e.Handled = true; } }
//public override void Refresh(UI.Forms.frmCommandEditor editor) //{ // //seleniumAction_SelectionChangeCommitted(null, null); //} public void seleniumAction_SelectionChangeCommitted(object sender, EventArgs e) { Core.Automation.Commands.SeleniumBrowserElementActionCommand cmd = (Core.Automation.Commands.SeleniumBrowserElementActionCommand) this; DataTable actionParameters = cmd.v_WebActionParameterTable; if (sender != null) { actionParameters.Rows.Clear(); } switch (ElementActionDropdown.SelectedItem) { case "Invoke Click": case "Clear Element": foreach (var ctrl in ElementParameterControls) { ctrl.Hide(); } break; case "Left Click": case "Middle Click": case "Right Click": case "Double Left Click": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("X Adjustment", 0); actionParameters.Rows.Add("Y Adjustment", 0); } break; case "Set Text": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Text To Set"); actionParameters.Rows.Add("Clear Element Before Setting Text"); actionParameters.Rows.Add("Encrypted Text"); actionParameters.Rows.Add("Optional - Click to Encrypt 'Text To Set'"); DataGridViewComboBoxCell encryptedBox = new DataGridViewComboBoxCell(); encryptedBox.Items.Add("Not Encrypted"); encryptedBox.Items.Add("Encrypted"); ElementsGridViewHelper.Rows[2].Cells[1] = encryptedBox; ElementsGridViewHelper.Rows[2].Cells[1].Value = "Not Encrypted"; var buttonCell = new DataGridViewButtonCell(); ElementsGridViewHelper.Rows[3].Cells[1] = buttonCell; ElementsGridViewHelper.Rows[3].Cells[1].Value = "Encrypt Text"; ElementsGridViewHelper.CellContentClick += ElementsGridViewHelper_CellContentClick; } DataGridViewComboBoxCell comparisonComboBox = new DataGridViewComboBoxCell(); comparisonComboBox.Items.Add("Yes"); comparisonComboBox.Items.Add("No"); //assign cell as a combobox if (sender != null) { ElementsGridViewHelper.Rows[1].Cells[1].Value = "No"; } ElementsGridViewHelper.Rows[1].Cells[1] = comparisonComboBox; break; case "Get Text": case "Get Matching Elements": case "Get Count": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Variable Name"); } break; case "Get Attribute": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Attribute Name"); actionParameters.Rows.Add("Variable Name"); } break; case "Get Options": actionParameters.Rows.Add("Attribute Name"); actionParameters.Rows.Add("Variable Name"); break; case "Select Option": actionParameters.Rows.Add("Selection Type"); actionParameters.Rows.Add("Selection Parameter"); DataGridViewComboBoxCell selectionTypeBox = new DataGridViewComboBoxCell(); selectionTypeBox.Items.Add("Select By Index"); selectionTypeBox.Items.Add("Select By Text"); selectionTypeBox.Items.Add("Select By Value"); selectionTypeBox.Items.Add("Deselect By Index"); selectionTypeBox.Items.Add("Deselect By Text"); selectionTypeBox.Items.Add("Deselect By Value"); selectionTypeBox.Items.Add("Deselect All"); //assign cell as a combobox if (sender != null) { ElementsGridViewHelper.Rows[0].Cells[1].Value = "Select By Text"; } ElementsGridViewHelper.Rows[0].Cells[1] = selectionTypeBox; break; case "Wait For Element To Exist": foreach (var ctrl in ElementParameterControls) { ctrl.Show(); } if (sender != null) { actionParameters.Rows.Add("Timeout (Seconds)"); } break; case "Switch to frame": foreach (var ctrl in ElementParameterControls) { ctrl.Hide(); } break; default: break; } ElementsGridViewHelper.DataSource = v_WebActionParameterTable; }
public void BindButtonConfiguration(DataGridView gridView, BindingSource bindingSource) { CecButtonGridView = gridView; DataGridViewCell buttonCellTemplate = new DataGridViewTextBoxCell(); CecButtonGridView.Columns.Add(new DataGridViewColumn(buttonCellTemplate) { DataPropertyName = "CecButtonName", Name = Resources.config_cec_button, ReadOnly = true, Width = 150 }); DataGridViewButtonCell mappedToCellTemplate = new DataGridViewButtonCell(); CecButtonGridView.Columns.Add(new DataGridViewColumn(mappedToCellTemplate) { DataPropertyName = "MappedButtonName", Name = Resources.config_button_mapped_to, ReadOnly = true, Width = 350 }); bindingSource.DataSource = ButtonConfig; CecButtonGridView.DataSource = bindingSource; gridView.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args) { DataGridView grid = sender as DataGridView; var data = grid != null ? grid.Rows[args.RowIndex].DataBoundItem as CecButtonConfigItem : null; if (data == null || !data.Enabled) { args.CellStyle.ForeColor = Color.Gray; } }; gridView.CellClick += delegate(object sender, DataGridViewCellEventArgs args) { var item = args.RowIndex < ButtonConfig.Count ? ButtonConfig[args.RowIndex] : null; if (item == null) { return; } if (args.ColumnIndex >= 0) { (new CecButtonConfigUI(item)).ShowDialog(); } else { var mappedButton = ButtonConfig[item.Key]; if (mappedButton == null || mappedButton.Value.Empty()) { return; } var controlWindow = FindInstance(); if (controlWindow != IntPtr.Zero && item.Key.Duration == 0) { mappedButton.Value.Transmit(controlWindow); } } }; foreach (var item in _buttonConfig) { item.SettingChanged += delegate { gridView.Refresh(); }; } }
private void Example2() { //DataGridView _grid = new DataGridView(); //_grid.Dock = DockStyle.Fill;//Задает позицию и способ закрепления элемента управления. dataGridView2.AllowUserToAddRows = false;//Возвращает или задает значение, указывающее, отображается ли для пользователя параметр добавления строк. // выравнивание всех значений по центру dataGridView2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //Controls.Add(_grid); dataGridView2.Columns.Add(new DataGridViewTextBoxColumn { HeaderText = "TextBoxColumn", AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells } ); dataGridView2.Columns.Add(new DataGridViewLinkColumn()); dataGridView2.Columns[1].HeaderText = "LinkColumn"; dataGridView2.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView2.Columns.Add(new DataGridViewButtonColumn()); dataGridView2.Columns[2].HeaderText = "ButtonColumn"; dataGridView2.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView2.Columns.Add(new DataGridViewCheckBoxColumn()); dataGridView2.Columns[3].HeaderText = "CheckBoxColumn"; dataGridView2.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView2.Columns.Add(new DataGridViewComboBoxColumn()); dataGridView2.Columns[4].HeaderText = "ComboBoxColumn"; dataGridView2.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView2.Columns.Add(new DataGridViewImageColumn()); dataGridView2.Columns[5].HeaderText = "ViewImageColumn"; //dataGridView2.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView2.Rows.Add(); // добавляет одну строку, заполняя ее значениями по умолчанию // добавляем еще 4 строки - все ячейки TextBox for (int i = 0; i < 4; i++) { DataGridViewRow heter_row = new DataGridViewRow(); for (int j = 0; j < dataGridView2.Columns.Count; j++) { heter_row.Cells.Add(new DataGridViewTextBoxCell()); } switch (i) { case 0: heter_row.HeaderCell.Value = "Value"; break; case 1: heter_row.HeaderCell.Value = "ValueType"; break; case 2: heter_row.HeaderCell.Value = "FormattedValue"; break; case 3: heter_row.HeaderCell.Value = "FormattedValueType"; break; } dataGridView2.Rows.Add(heter_row); } // Корректирует ширину заголовков строк в соответствии с содержимым заголовка (автоподбор ширины заголовков) dataGridView2.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; // изменяется автоматически // регулируются один раз - автоматически не изменяется //dataGridView2.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); // Заполнение строки 0 DataGridViewRow row0 = dataGridView2.Rows[0]; row0.HeaderCell.Value = "Внешний вид ячейки"; DataGridViewTextBoxCell cell0 = (DataGridViewTextBoxCell)row0.Cells[0]; cell0.Value = "Я просто текст"; DataGridViewLinkCell cell1 = (DataGridViewLinkCell)row0.Cells[1]; cell1.Value = "Я ссылка!"; DataGridViewButtonCell cell2 = (DataGridViewButtonCell)row0.Cells[2]; cell2.Value = "Я кнопка"; DataGridViewCheckBoxCell cell3 = (DataGridViewCheckBoxCell)row0.Cells[3]; cell3.Value = true; DataGridViewComboBoxCell cell4 = (DataGridViewComboBoxCell)row0.Cells[4]; cell4.Items.AddRange(new string[] { "Trace", "Debug", "Release" }); cell4.Value = "Release"; DataGridViewImageCell cell5 = (DataGridViewImageCell)row0.Cells[5]; cell5.ImageLayout = DataGridViewImageCellLayout.Zoom; //cell5.Value = Image.FromFile("!.bmp"); //cell5.Value = DataGridView.Properties.Resources._; // image-ресурс "!.bmp" cell5.Value = WFDataGreitView.Properties.Resources.HappyDude; // image-ресурс "HappyDude" // Заполнение строки 1 for (int j = 0; j < dataGridView2.Columns.Count; j++) { dataGridView2.Rows[1].Cells[j].Value = dataGridView2.Rows[0].Cells[j].Value.ToString(); } // Заполнение строки 2 for (int j = 0; j < dataGridView2.Columns.Count; j++) { dataGridView2.Rows[2].Cells[j].Value = dataGridView2.Rows[0].Cells[j].ValueType.ToString(); } // Заполнение строки 3 for (int j = 0; j < dataGridView2.Columns.Count; j++) { dataGridView2.Rows[3].Cells[j].Value = dataGridView2.Rows[0].Cells[j].FormattedValue.ToString(); } // Заполнение строки 4 for (int j = 0; j < dataGridView2.Columns.Count; j++) { dataGridView2.Rows[4].Cells[j].Value = dataGridView2.Rows[0].Cells[j].FormattedValueType.ToString(); /**/ } }
private Panel BuildPanelLista() { var pnlLista = new Panel { Dock = DockStyle.Fill }; pnlLista.SuspendLayout(); pnlLista.Dock = DockStyle.Fill; // Crear gridview this.GrdLista = new DataGridView() { Dock = DockStyle.Fill, AllowUserToResizeRows = false, RowHeadersVisible = false, AutoGenerateColumns = false, MultiSelect = false, AllowUserToAddRows = false, EnableHeadersVisualStyles = false, SelectionMode = DataGridViewSelectionMode.FullRowSelect, //BackColor = Color.FromArgb(113, 162, 208), }; this.GrdLista.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; this.GrdLista.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(23, 160, 219); this.GrdLista.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.GrdLista.ColumnHeadersHeight = 30; this.GrdLista.ColumnHeadersDefaultCellStyle.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular); //texto var textCellTemplate0 = new DataGridViewTextBoxCell(); var textCellTemplate1 = new DataGridViewTextBoxCell(); var textCellTemplate2 = new DataGridViewTextBoxCell(); var textCellTemplate3 = new DataGridViewTextBoxCell(); var textCellTemplate4 = new DataGridViewTextBoxCell(); var textCellTemplate5 = new DataGridViewTextBoxCell(); //botones var buttonCellTemplate6 = new DataGridViewButtonCell(); var buttonCellTemplate7 = new DataGridViewButtonCell(); var buttonCellTemplate8 = new DataGridViewButtonCell(); //texto Color colorCeldasDatos = Color.PapayaWhip; textCellTemplate0.Style.BackColor = Color.FromArgb(104, 168, 216); textCellTemplate0.Style.ForeColor = Color.Black; textCellTemplate1.Style.BackColor = Color.FromArgb(104, 168, 216); textCellTemplate1.Style.ForeColor = Color.Black; textCellTemplate1.Style.Alignment = DataGridViewContentAlignment.MiddleRight; textCellTemplate2.Style.BackColor = colorCeldasDatos; textCellTemplate2.Style.ForeColor = Color.Black; textCellTemplate2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; textCellTemplate3.Style.BackColor = colorCeldasDatos; textCellTemplate3.Style.ForeColor = Color.Black; textCellTemplate3.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; textCellTemplate4.Style.BackColor = colorCeldasDatos; textCellTemplate4.Style.ForeColor = Color.Black; textCellTemplate4.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; textCellTemplate5.Style.BackColor = colorCeldasDatos; textCellTemplate5.Style.ForeColor = Color.Black; textCellTemplate5.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; //botones buttonCellTemplate6.Style.BackColor = Color.FromArgb(80, 80, 80); buttonCellTemplate6.Style.ForeColor = Color.White; buttonCellTemplate6.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; buttonCellTemplate6.Style.Font = new Font(FontFamily.GenericMonospace, 11, FontStyle.Regular); buttonCellTemplate7.Style.BackColor = Color.FromArgb(219, 43, 43); buttonCellTemplate7.Style.ForeColor = Color.White; buttonCellTemplate7.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; buttonCellTemplate7.Style.Font = new Font(FontFamily.GenericMonospace, 11, FontStyle.Regular); buttonCellTemplate8.Style.BackColor = colorCeldasDatos; buttonCellTemplate8.Style.ForeColor = Color.Black; buttonCellTemplate8.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; buttonCellTemplate8.Style.Font = new Font(FontFamily.GenericMonospace, 11, FontStyle.Regular); /*this.tipo, * this.Doi, * this.Issn, * this.año, * this.pagIn, * this.pagFin, * this.autor*/ var columna0 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate0, HeaderText = "#", Width = 5, ReadOnly = true }; var columna1 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate1, HeaderText = "tipo", Width = 20, ReadOnly = true }; var columna2 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate3, HeaderText = "Doi", Width = 15, ReadOnly = true }; var columna3 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate2, HeaderText = "Issn", Width = 20, ReadOnly = true }; var columna4 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate4, HeaderText = "Año", Width = 15, ReadOnly = true }; var columna5 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate4, HeaderText = "Pagina de Inicio", Width = 15, ReadOnly = true }; var columna6 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate4, HeaderText = "Pagina de Final", Width = 15, ReadOnly = true }; var columna7 = new DataGridViewTextBoxColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = textCellTemplate4, HeaderText = "Autor", Width = 15, ReadOnly = true }; var columna8 = new DataGridViewButtonColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = buttonCellTemplate6, HeaderText = "Editar", Width = 20, ReadOnly = true, }; var columna9 = new DataGridViewButtonColumn { SortMode = DataGridViewColumnSortMode.NotSortable, CellTemplate = buttonCellTemplate7, HeaderText = "Eliminar", Width = 20, ReadOnly = true, }; this.GrdLista.Columns.AddRange(new DataGridViewColumn[] { columna0, columna1, columna2, columna3, columna4, columna5, columna6, columna7, columna8, columna9 }); this.GrdLista.SelectionChanged += (sender, e) => this.FilaSeleccionada(); pnlLista.Controls.Add(this.GrdLista); pnlLista.ResumeLayout(false); return(pnlLista); }
private void dgvMileStoneList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } if (e.ColumnIndex == 9) { string Submilestoneid = dgvMileStoneList.Rows[e.RowIndex].Cells["submilestoneid"].Value.ToString(); DataGridViewButtonCell b = dgvMileStoneList.Rows[e.RowIndex].Cells["ConfirmOK"] as DataGridViewButtonCell; if (b.Value.ToString() == "确认") { for (int i = 0; i < e.RowIndex; i++) { DataGridViewButtonCell b2 = dgvMileStoneList.Rows[i].Cells["ConfirmOK"] as DataGridViewButtonCell; if (b2.Value.ToString() == "确认") { MessageBox.Show("请先确认前边阶段的里成本!"); return; } } ///确认 /// try { SelectDate frmSelectDate = new SelectDate(); if (frmSelectDate.ShowDialog() == DialogResult.OK) { if (WSAL.WSMilestone.Confirm(Submilestoneid, SubProjectID, frmSelectDate.Value)) { b.Value = "取消"; dgvMileStoneList.Rows[e.RowIndex].Cells["FinishDate"].Value = frmSelectDate.Value; frmSelectDate.Dispose(); MessageBox.Show("确认成功!"); return; } else { frmSelectDate.Dispose(); MessageBox.Show("确认失败!"); return; } } } catch { MessageBox.Show("确认失败!"); return; } } else { for (int i = e.RowIndex + 1; i < dgvMileStoneList.Rows.Count; i++) { DataGridViewButtonCell b2 = dgvMileStoneList.Rows[i].Cells["ConfirmOK"] as DataGridViewButtonCell; if (b2.Value.ToString() == "取消") { MessageBox.Show("请先取消后边阶段的里成本!"); return; } } ///取消 try { SelectDate frmSelectDate = new SelectDate(); if (frmSelectDate.ShowDialog() == DialogResult.OK) { if (WSAL.WSMilestone.CancelConfirm(Submilestoneid, SubProjectID)) { b.Value = "确认"; frmSelectDate.Dispose(); dgvMileStoneList.Rows[e.RowIndex].Cells["FinishDate"].Value = ""; MessageBox.Show("取消成功!"); return; } else { frmSelectDate.Dispose(); MessageBox.Show("取消失败!"); return; } } } catch { MessageBox.Show("取消失败!"); return; } } } }
/// <summary> /// 设置界面信息 /// </summary> public void initUI() { dgvDescF.Rows.Clear(); dgvDescB.Rows.Clear(); for (int i = 0; i < 4; i++) { dgvDescF.Rows.Add(); } dgvDescF.Rows[0].Cells[0].Value = "X"; dgvDescF.Rows[1].Cells[0].Value = "Y"; dgvDescF.Rows[2].Cells[0].Value = "时间"; dgvDescF.Rows[3].Cells[0].Value = "名称"; for (int i = 0; i < 4; i++) { dgvDescB.Rows.Add(); } dgvDescB.Rows[0].Cells[0].Value = "X"; dgvDescB.Rows[1].Cells[0].Value = "Y"; dgvDescB.Rows[2].Cells[0].Value = "时间"; dgvDescB.Rows[3].Cells[0].Value = "名称"; dgvParamF.Rows.Clear(); dgvParamB.Rows.Clear(); //init dgvParam for (int i = 0; i < 4; i++) //4行 { dgvParamF.Rows.Add(); } foreach (DataGridViewRow row in dgvParamF.Rows) { foreach (DataGridViewCell cell in row.Cells) { cell.ReadOnly = false; } } DataGridViewRow dr = new DataGridViewRow(); for (int i = 0; i < 8; i++) { DataGridViewButtonCell btnCell = new DataGridViewButtonCell(); btnCell.Value = "测试"; btnCell.Style.BackColor = Color.Gray; btnCell.Style.ForeColor = Color.White; dr.Cells.Add(btnCell); } dgvParamF.Rows.Add(dr); //--------------------------------------------------- //init dgvParam for (int i = 0; i < 4; i++) //4行 { dgvParamB.Rows.Add(); } foreach (DataGridViewRow row in dgvParamB.Rows) { foreach (DataGridViewCell cell in row.Cells) { cell.ReadOnly = false; } } dr = new DataGridViewRow(); for (int i = 0; i < 8; i++) { DataGridViewButtonCell btnCell = new DataGridViewButtonCell(); btnCell.Value = "测试"; btnCell.Style.BackColor = Color.Gray; btnCell.Style.ForeColor = Color.White; dr.Cells.Add(btnCell); } dgvParamB.Rows.Add(dr); makeTeams(); if (client != null) { tbxIdCardNo.Text = client.idCardNo; tbxPhoneNo.Text = client.phoneNo; tbxName.Text = client.name; tbxAge.Text = client.age + ""; tbxHeight.Text = client.height; tbxWeight.Text = client.weight; cbxGender.SelectedIndex = client.gender.Equals(Dict.MALE) ? 0 : 1; if (client.param != null) { showClientParam(); } else { loadParamDFT(null, null); } } else { loadParamDFT(null, null); } }
private void listBoxTasks_SelectedIndexChanged(object sender, EventArgs e) { ITask task = MyJob.Tasks.Skip(listBoxTasks.SelectedIndex).Take(1).FirstOrDefault(); DGTasks.Rows.Clear(); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_Name, task.Name); int i = DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_Configuration, ""); DataGridViewButtonCell btn = new DataGridViewButtonCell(); DGTasks.Rows[i].Cells[1] = btn; DGTasks.Rows[i].Cells[1].Value = AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_SeeClearValue; DGTasks.Rows[i].Cells[1].Tag = task.GetClearConfiguration(); i = DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_Body, ""); btn = new DataGridViewButtonCell(); DGTasks.Rows[i].Cells[1] = btn; DGTasks.Rows[i].Cells[1].Value = AMSExplorer.Properties.Resources.AssetInformation_DoDisplayAuthorizationPolicyOption_SeeValue; DGTasks.Rows[i].Cells[1].Tag = task.TaskBody; DGTasks.Rows.Add("Id", task.Id); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_AssetInformation_Load_State, task.State); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_JobInformation_Load_Priority, task.Priority); if (task.StartTime != null) { DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_JobInformation_Load_StartTime, ((DateTime)task.StartTime).ToLocalTime().ToString("G")); } if (task.EndTime != null) { DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_JobInformation_Load_EndTime, ((DateTime)task.EndTime).ToLocalTime().ToString("G")); } DGTasks.Rows.Add(AMSExplorer.Properties.Resources.DataGridViewIngestManifest_Init_Progress, task.Progress); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_Duration, task.RunningDuration); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_PerfMessage, task.PerfMessage); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_EncryptionKeyId, task.EncryptionKeyId); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_EncryptionScheme, task.EncryptionScheme); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_EncryptionVersion, task.EncryptionVersion); // let's get the name of the processor IMediaProcessor processor = JobInfo.GetMediaProcessorFromId(task.MediaProcessorId, _context); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_MediaprocessorId, task.MediaProcessorId); if (processor != null) { DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_MediaprocessorName, processor.Name); } DGTasks.Rows.Add(AMSExplorer.Properties.Resources.AssetInformation_DoDisplayFileProperties_Options, task.Options); DGTasks.Rows.Add(AMSExplorer.Properties.Resources.JobInformation_listBoxTasks_SelectedIndexChanged_InitializationVector, task.InitializationVector); string sid = ""; try { if (task.InputAssets.Count() > 1) { sid = " #{0}"; } else { sid = ""; } for (int j = 0; j < task.InputAssets.Count(); j++) { var s = string.Format(sid, j + 1); DGTasks.Rows.Add(string.Format("Input asset{0} Name", s), task.InputAssets[j].Name); DGTasks.Rows.Add(string.Format("Input asset{0} Id", s), task.InputAssets[j].Id); } } catch { DGTasks.Rows.Add("Input asset(s)", "<error, deleted?>"); } try { if (task.OutputAssets.Count() > 1) { sid = " #{0}"; } else { sid = ""; } for (int j = 0; j < task.OutputAssets.Count(); j++) { var s = string.Format(sid, j + 1); DGTasks.Rows.Add(string.Format("Output asset{0} Name", s), task.OutputAssets[j].Name); DGTasks.Rows.Add(string.Format("Output asset{0} Id", s), task.OutputAssets[j].Id); DGTasks.Rows.Add(string.Format("Output asset{0} Format Option", s), task.OutputAssets[j].FormatOption); } } catch { DGTasks.Rows.Add("Output asset(s)", "<error, deleted?>"); } TaskSize taskSizePrice = JobInfo.CalculateTaskSize(task, _context); if ((taskSizePrice.InputSize != -1) && (taskSizePrice.OutputSize != -1)) { DGTasks.Rows.Add("Input size", AssetInfo.FormatByteSize(taskSizePrice.InputSize)); DGTasks.Rows.Add("Output size", AssetInfo.FormatByteSize(taskSizePrice.OutputSize)); } else { DGTasks.Rows.Add("Input/output size", "undefined, task did not finish or one of the assets has been deleted"); } for (int j = 0; j < task.ErrorDetails.Count(); j++) { DGTasks.Rows.Add("Error", task.ErrorDetails[j].Code + ": " + task.ErrorDetails[j].Message); } }
public Session() { InitializeComponent(); using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); var stm = "SELECT sessions.session_id, sessions.title, time_slots.start_time, time_slots.end_time, speaker.name, rooms.room_name" + " FROM sessions" + " INNER JOIN time_slots" + " ON sessions.time_slots_id = time_slots.time_slots_id"+ " INNER JOIN speaker" + " ON sessions.speaker_id = speaker.speaker_id"+ " INNER JOIN rooms" + " ON sessions.room_id = rooms.room_id"; var cmd = new MySqlCommand(stm, mysqlCon); MySqlDataReader rdr = cmd.ExecuteReader(); DataTable dt = new DataTable(); _dt = dt; dt.Columns.Add("id", typeof(int)); dt.Columns.Add("title", typeof(string)); dt.Columns.Add("start_time", typeof(string)); dt.Columns.Add("end_time", typeof(string)); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("room_name", typeof(string)); dt.Columns.Add("edit", typeof(string)); dt.Columns.Add("delete", typeof(string)); dt.Columns.Add("save", typeof(string)); dt.Columns.Add("cancel", typeof(string)); while (rdr.Read()) { DataRow dr = dt.NewRow(); dr["id"] = rdr.GetInt32(0); dr["title"] = rdr.GetString(1); dr["start_time"] = rdr.GetString(2); dr["end_time"] = rdr.GetString(3); dr["name"] = rdr.GetString(4); dr["room_name"] = rdr.GetString(5); dr["edit"] = "1"; dr["delete"] = "1"; dr["save"] = "1"; dr["cancel"] = "1"; dt.Rows.Add(dr); } dataGridView1.Columns.Add("id", "ID"); dataGridView1.Columns.Add("title", "Title"); dataGridView1.Columns.Add("time_slots", "Time Slot"); dataGridView1.Columns.Add("room_name", "Room"); dataGridView1.Columns.Add("name", "Speaker"); dataGridView1.Columns.Add("edit", "Edit"); dataGridView1.Columns.Add("delete", "Delete"); dataGridView1.Columns.Add("save", "Save"); dataGridView1.Columns.Add("cancel", "Cancel"); dataGridView1.Columns["time_slots"].ReadOnly = true; dataGridView1.Columns["title"].ReadOnly = true; dataGridView1.Columns["room_name"].ReadOnly = true; dataGridView1.Columns["name"].ReadOnly = true; dataGridView1.Columns["id"].Visible = false; dataGridView1.Columns["save"].Visible = false; dataGridView1.Columns["cancel"].Visible = false; dataGridView1.AllowUserToAddRows = false; string[] lst_dados = new string[5]; foreach (DataRow dr1 in dt.Rows) { lst_dados[0] = dr1["id"].ToString(); lst_dados[1] = dr1["title"].ToString(); var start_time = DateTime.Parse((dr1["start_time"].ToString())); var end_time = DateTime.Parse((dr1["end_time"].ToString())); lst_dados[2] = start_time.ToString("hh:mm tt") + (" - ") + end_time.ToString("hh:mm tt"); lst_dados[3] = dr1["name"].ToString(); lst_dados[4] = dr1["room_name"].ToString(); this.dataGridView1.Rows.Add(lst_dados); if (dr1["edit"].ToString() == "1") { DataGridViewButtonCell btn = new DataGridViewButtonCell(); btn.Value = "Edit"; btn.UseColumnTextForButtonValue = true; this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells["edit"] = btn; } if (dr1["delete"].ToString() == "1") { DataGridViewButtonCell btn = new DataGridViewButtonCell(); btn.Value = "Delete"; btn.UseColumnTextForButtonValue = true; this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells["delete"] = btn; } if (dr1["save"].ToString() == "1") { DataGridViewButtonCell btn = new DataGridViewButtonCell(); btn.Value = "Save"; btn.UseColumnTextForButtonValue = true; this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells["save"] = btn; } if (dr1["cancel"].ToString() == "1") { DataGridViewButtonCell btn = new DataGridViewButtonCell(); btn.Value = "Cancel"; btn.UseColumnTextForButtonValue = true; this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells["cancel"] = btn; } } mysqlCon.Close(); } this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick); }
private void dataGridView_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 3) { //return; DataGridViewButtonCell cell = (DataGridViewButtonCell)dataGridViewUnSubmitted.Rows[e.RowIndex].Cells[e.ColumnIndex]; if ((cell == null) || (cell.Tag == null)) { return; } string url = cell.Tag.ToString(); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true }); return; // } else if (e.ColumnIndex == 4) { if (PipeOps == null) { return; } DataGridViewButtonCell cell = (DataGridViewButtonCell)dataGridViewUnSubmitted.Rows[e.RowIndex].Cells[e.ColumnIndex]; if ((cell == null) || (cell.Tag == null)) { return; } if (cell.Tag is JobItem) { JobItem jobItem = (JobItem)cell.Tag; PipeOps.MessageClass message = new PipeOps.MessageClass(); message.Recipient = "LinkedIn Job Hunter"; message.Command = "Find"; MessageData messageData = new MessageData(); if (jobItem.JobId != 0) { messageData.routing = "JobId"; string data = jobItem.JobId.ToString(); messageData.data = data; } else { messageData.routing = "Company"; //and jobs string data = string.Format("\"{0}\" and \"{1}\"", jobItem.company, jobItem.title); messageData.data = data; } message.Message = JsonConvert.SerializeObject(messageData); PipeOps.SendMsg(message); } return; // } }