private void AddToDGV(DataGridView DataGridView1, DataSet ds) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = ds.Tables[0].Rows[i]["id"]; dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = ds.Tables[0].Rows[i]["tzmc"]; dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = ds.Tables[0].Rows[i]["ds"]; dgvr.Cells.Add(cell); DataGridView1.Rows.Add(dgvr); } }
private void LoadDynamicsGrid() { dataGridView3.Rows.Clear(); for (int i = 0; i < Dynamics.Count; i++) { dataGridView3.Rows.Add(); dataGridView3.Rows[i].Tag = Dynamics[i].ID; dataGridView3["D_ID", i] = new DataGridViewTextBoxCell { Value = Dynamics[i].ID }; dataGridView3["DynamicName", i] = new DataGridViewTextBoxCell { Value = Dynamics[i].Name }; dataGridView3["DynamicExpression", i] = new DataGridViewTextBoxCell { Value = Dynamics[i].Expression }; } }
void IResultWriter.WriteRows(object[][] rows, int rowCount) { var dataGridView = DataGridViews[DataGridViews.Count - 1]; var targetRows = dataGridView.Rows; for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { var sourceRow = rows[rowIndex]; var targetRow = new DataGridViewRow(); var cells = targetRow.Cells; for (var columnIndex = 0; columnIndex < sourceRow.Length; columnIndex++) { var sourceValue = sourceRow[columnIndex]; var cell = new DataGridViewTextBoxCell(); cell.Value = sourceValue; cells.Add(cell); } targetRows.Add(targetRow); } }
private void customGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewTextBoxCell cell = customGridView1[e.ColumnIndex, e.RowIndex] as DataGridViewTextBoxCell; if (cell.Value.ToString().Trim() != string.Empty) { bool aaaa_ = false; double a_ = 0; aaaa_ = double.TryParse(cell.Value.ToString(), out a_); if (aaaa_ == false) { MessageBox.Show("Hanya Angka"); customGridView1[e.ColumnIndex, e.RowIndex].Value = 0; } } else { customGridView1[e.ColumnIndex, e.RowIndex].Value = 0; } }
/// <summary> /// 更改回文本方式 /// </summary> /// <param name="cell"></param> /// <returns></returns> public DataGridViewCell CellToTextBox(DataGridViewCell cell) { if (cell == null) { return(cell); } if (cell is DataGridViewComboBoxCell) { DataGridViewTextBoxCell textbox = new DataGridViewTextBoxCell(); if (cell.Value != null) { textbox.Value = cell.Value.ToString(); } else { textbox.Value = ""; } cell = textbox; } return(cell); }
private void button2_Click(object sender, EventArgs e) { DataGridViewRow filaNueva = new DataGridViewRow(); DataGridViewCell celLote = new DataGridViewTextBoxCell(); DataGridViewCell celMotivo = new DataGridViewTextBoxCell(); DataGridViewCell celInicio = new DataGridViewTextBoxCell(); DataGridViewCell celTermino = new DataGridViewTextBoxCell(); DataGridViewCell celObjetivo = new DataGridViewTextBoxCell(); celLote.Value = txt_lote2.Text; celMotivo.Value = txt_motivo.Text; celInicio.Value = mk_inactivo_inicio.Text; celTermino.Value = mk_inactivo_termino.Text; celObjetivo.Value = rc_observacion.Text; filaNueva.Cells.Add(celLote); filaNueva.Cells.Add(celMotivo); filaNueva.Cells.Add(celInicio); filaNueva.Cells.Add(celTermino); filaNueva.Cells.Add(celObjetivo); dataGridView2.Rows.Add(filaNueva); }
private void LoadItemsGrid() { dataGridView1.Rows.Clear(); for (int i = 0; i < Items.Count; i++) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].Tag = Items[i].ID; dataGridView1["ID", i] = new DataGridViewTextBoxCell { Value = Items[i].ID }; dataGridView1["ItemName", i] = new DataGridViewTextBoxCell { Value = Items[i].ItemName }; dataGridView1["Expression", i] = new DataGridViewTextBoxCell { Value = Items[i].Expression }; } }
private DataGridViewRow NewVmRow(VM vm) { System.Diagnostics.Trace.Assert(vm != null); var pvsProxy = vm.PvsProxy; var vmCell = new DataGridViewTextBoxCell(); var cacheEnabledCell = new DataGridViewTextBoxCell(); var pvsSiteCell = new DataGridViewTextBoxCell(); var statusCell = new DataGridViewTextBoxCell(); var newRow = new DataGridViewRow { Tag = vm }; newRow.Cells.AddRange(vmCell, cacheEnabledCell, pvsSiteCell, statusCell); UpdateRow(newRow, vm, pvsProxy); RegisterEventHandlers(vm, pvsProxy); return(newRow); }
private void addAnimBtn_Click(object sender, EventArgs e) { // Create cell to hold value DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = ""; // Create row for single cell DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(cell); // Add row to DataGridView animDataGridView.Rows.Add(row); // Select cell for editing animDataGridView.CurrentCell = cell; animDataGridView.BeginEdit(false); SetChangesMade(true); }
/// <summary> /// 初始化grid /// </summary> /// <param name="view"></param> /// <param name="colum">第一列显示内容</param> public void InitDataGridView(DataGridView view, List <string> colum) { DataGridViewTextBoxColumn txtClum = new DataGridViewTextBoxColumn(); dataGridView1.Columns.Add(txtClum); for (int i = 0; i < columInfo.Count; i++) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell(); textboxcell.Value = colum[i]; row.Cells.Add(textboxcell); // row.HeaderCell.; dataGridView1.AllowUserToAddRows = false; // dataGridView1.RowHeadersVisible = false; //dataGridView1.ColumnHeadersVisible = false; dataGridView1.Rows.Add(row); } }
private DataGridViewCell NewDataCell(VdfSignal signal, SubFunction subFunction, int row) { var desc = signal.VdfValueDesc; if (desc is VdfBcdValueDesc || desc is VdfAsciiValueDesc) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = VdfEncoder.Encode(subFunction.Data, signal); cell.Tag = signal; return(cell); } else if (desc is VdfPhyValueDesc) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = VdfEncoder.Encode(subFunction.Data, signal); //设置单位 dataGridView.Rows[row].Cells["ColumnUnit"].Value = (desc as VdfPhyValueDesc).Unit; cell.Tag = signal; return(cell); } else if (desc is VdfXncodeValueDesc) { DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); VdfXncodeValueDesc xncodeDesc = (VdfXncodeValueDesc)desc; foreach (var entry in xncodeDesc.EntryTable) { cell.Items.Add(entry.Value); } cell.Value = VdfEncoder.Encode(subFunction.Data, signal); //这儿需要进行解码 cell.Tag = signal; return(cell); } else { throw new ArgumentException("Unsupported VdfValueDesc Type: " + signal.GetType().Name); } }
/// <summary> /// 加载数据 /// </summary> private void LoadData() { dgvStrategy.Rows.Clear(); if (!string.IsNullOrEmpty(StockNo)) { DataTable dt = Strategy.GetList(string.Format(" StockNo='{0}'", StockNo)).Tables[0]; foreach (DataRow dr in dt.Rows) { if (bool.Parse(dr["BasePoint"].ToString())) { btngenrerate.Enabled = false; txtBaseAmount.Enabled = false; txtBasePoint.Enabled = false; } } foreach (DataRow dr in dt.Rows) { DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewTextBoxCell cellStockNo = new DataGridViewTextBoxCell(); cellStockNo.Value = dr["StockNo"]; dgvr.Cells.Add(cellStockNo); DataGridViewTextBoxCell cellStockName = new DataGridViewTextBoxCell(); cellStockName.Value = dr["StockName"]; dgvr.Cells.Add(cellStockName); DataGridViewTextBoxCell cellPrice = new DataGridViewTextBoxCell(); cellPrice.Value = dr["Price"]; dgvr.Cells.Add(cellPrice); DataGridViewTextBoxCell cellAmount = new DataGridViewTextBoxCell(); cellAmount.Value = dr["Amount"];; dgvr.Cells.Add(cellAmount); DataGridViewCheckBoxCell cellHolgFlag = new DataGridViewCheckBoxCell(); cellHolgFlag.Value = bool.Parse(dr["HoldFlag"].ToString()); dgvr.Cells.Add(cellHolgFlag); DataGridViewCheckBoxCell cellBaseFlag = new DataGridViewCheckBoxCell(); cellBaseFlag.Value = bool.Parse(dr["BasePoint"].ToString()); dgvr.Cells.Add(cellBaseFlag); dgvStrategy.Rows.Add(dgvr); } } }
private void calcButton_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView.Rows) { row.Cells[_nameColumn.Name].Style.BackColor = Color.White; DataGridViewTextBoxCell gradeCell = (DataGridViewTextBoxCell)row.Cells[_gradeColumn.Name]; try { Expression ex = new Expression(algorithmBox.Text); decimal maxScore = 0; decimal totalScore = 0; _taskColumns.ForEach(s => { DataGridViewNumericUpDownCell cell = (DataGridViewNumericUpDownCell)row.Cells[s.Name]; if (string.IsNullOrWhiteSpace((string)cell.FormattedValue)) { return; } maxScore += cell.Maximum; totalScore += decimal.Parse((string)cell.FormattedValue); ex.Parameters["score"] = decimal.Parse((string)cell.FormattedValue); ex.Parameters["maxScore"] = cell.Maximum; cell.Style.BackColor = GetColor((float)NCalcDoubleParser.Parse(ex.Evaluate()), 1); }); ex.Parameters["score"] = (double)totalScore; ex.Parameters["maxScore"] = (double)maxScore; double grade = 6 - (NCalcDoubleParser.Parse(ex.Evaluate()) * 5); gradeCell.Value = (grade.ToString(CultureInfo.InvariantCulture).Length > 13 ? grade.ToString(CultureInfo.InvariantCulture).Remove(13) : grade.ToString(CultureInfo.InvariantCulture)) + " " + TexGrade(grade); gradeCell.Style.BackColor = GetColor(grade - 1, 5); } catch (Exception) { gradeCell.Value = ""; } } dataGridView.Sort(_nameColumn, ListSortDirection.Ascending); }
private void ShowItems() { try { dataGridView1.Rows.Clear(); foreach (PlcScanItems item in _plcData.m_ScanDataList) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell addrTypeCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell addrCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell dataTypeCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell indexCell = new DataGridViewTextBoxCell(); DataGridViewCheckBoxCell refreshchkCell = new DataGridViewCheckBoxCell(); nameCell.Value = item.strName; addrTypeCell.Value = item.AddressType.ToString(); addrCell.Value = item.Address; dataTypeCell.Value = item.DataType.ToString(); valueCell.Value = item.strValue; indexCell.Value = item.Index.ToString(); refreshchkCell.Value = item.Refresh; row.Cells.Add(nameCell); row.Cells.Add(addrTypeCell); row.Cells.Add(addrCell); row.Cells.Add(dataTypeCell); row.Cells.Add(valueCell); row.Cells.Add(indexCell); row.Cells.Add(refreshchkCell); dataGridView1.Rows.Add(row); } } catch (Exception) { } }
private void frmCustomerView_Load(object sender, EventArgs e) { tmrDateTime_Tick(sender, e); int currentCustomerNum = fileClass.getcurrentCustomerNum(); int currentAccountNum = 0; ArrayList returnedData = fileClass.readFile(); Customer thisCustomer = (Customer)returnedData[currentCustomerNum]; lblCustomerName.Text = thisCustomer.getfirstName() + " " + thisCustomer.getsurname(); lblCustomerDOB.Text = thisCustomer.getdob(); lblCustomerHouseNameOrNum.Text = thisCustomer.gethouseNameNumber(); lblCustomerStreet.Text = thisCustomer.getstreetName(); lblCustomerAddress.Text = thisCustomer.getaddressArea(); lblCustomerTownOrCity.Text = thisCustomer.getcityTown(); lblCustomerCounty.Text = thisCustomer.getcounty(); lblCustomerPostcode.Text = thisCustomer.getpostcode(); foreach (Account oneAccount in thisCustomer.getaccountList()) { DataGridViewRow dgvRow = new DataGridViewRow(); DataGridViewCell dgvCell = new DataGridViewTextBoxCell(); dgvCell.Value = currentAccountNum; dgvRow.Cells.Add(dgvCell); dgvCell = new DataGridViewTextBoxCell(); dgvCell.Value = oneAccount.getnickName(); dgvRow.Cells.Add(dgvCell); dgvCell = new DataGridViewTextBoxCell(); dgvCell.Value = oneAccount.getcurrentBalance(); dgvRow.Cells.Add(dgvCell); dgvAccounts.Rows.Add(dgvRow); currentAccountNum++; } dgvAccounts.Refresh(); }
private void dgvDetalle_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewRow filaActual = dgvDetalle.CurrentRow; if (dgvDetalle.Columns[e.ColumnIndex].Name == "Producto") { DataGridViewComboBoxCell combo = dgvDetalle.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewComboBoxCell; int idProducto = (int)combo.Value; foreach (var p in productos) { if (p.Id == idProducto) { descripcion = p.Descripcion.ToString(); precio = p.Precio; break; } } DataGridViewTextBoxCell celdaDescripcion = filaActual.Cells["Descripcion"] as DataGridViewTextBoxCell; celdaDescripcion.Value = descripcion; DataGridViewTextBoxCell celdaPrecio = filaActual.Cells["Precio"] as DataGridViewTextBoxCell; celdaPrecio.Value = precio; } if (dgvDetalle.Columns[e.ColumnIndex].Name == "Cantidad") { // Calculamos el total de la fila: Cantidad * Precio decimal total = precio * Convert.ToInt32(filaActual.Cells["Cantidad"].Value); DataGridViewTextBoxCell celdaTotal = filaActual.Cells["Total"] as DataGridViewTextBoxCell; celdaTotal.Value = total; granTotal = granTotal + total; txtTotalF.Text = granTotal.ToString(); } }
private void btnNhapDiem_Click(object sender, EventArgs e) { //Gọi hàm để load dgv học sinh chưa nhập điểm LoaddgvHSNhapDiem(); if (dgvBangDiem.Rows.Count == 0 || dgvBangDiem.DataSource == null) { MessageBox.Show("Học sinh lớp" + lblLop.Text + "đã được nhập điểm rồi !", "Thông Báo!"); NutNhan = true; LoadDSDiemHS(); return; } if (TaoCot == 0) { //Thêm vào một cột điểm cho dgvBangDiem //Cột điểm miệng DataGridViewColumn clDiemMieng = new DataGridViewColumn(); DataGridViewCell cell = new DataGridViewTextBoxCell(); clDiemMieng.CellTemplate = cell; clDiemMieng.Name = "DiemMieng"; dgvBangDiem.Columns.Add(clDiemMieng); //Cột điểm 15 phút DataGridViewColumn clDiem15Phut = new DataGridViewColumn(); clDiem15Phut.CellTemplate = cell; clDiem15Phut.Name = "Diem15Phut"; dgvBangDiem.Columns.Add(clDiem15Phut); //Một tiết DataGridViewColumn cl1Tiet = new DataGridViewColumn(); cl1Tiet.CellTemplate = cell; cl1Tiet.Name = "Diem1Tiet"; dgvBangDiem.Columns.Add(cl1Tiet); //Thi DataGridViewColumn clDiemThi = new DataGridViewColumn(); clDiemThi.CellTemplate = cell; clDiemThi.Name = "DiemThi"; dgvBangDiem.Columns.Add(clDiemThi); TaoCot++; //Nút nhấn NutNhan = false; } }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewComboBoxCell type = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[0]; if (type.Value == null) { return; } DataGridViewTextBoxCell value = (DataGridViewTextBoxCell)dataGridView1.Rows[e.RowIndex].Cells[1]; DataGridViewTextBoxCell duration = (DataGridViewTextBoxCell)dataGridView1.Rows[e.RowIndex].Cells[2]; if ("Write" == (string)type.Value || "Loop" == (string)type.Value) { value.Style.BackColor = Color.White; value.ReadOnly = false; return; } else { if ("Delay" == (string)type.Value) { value.Style.BackColor = Color.LightGray; value.Value = ""; } else if ("Stop" == (string)type.Value) { value.Style.BackColor = Color.LightGray; value.Value = ""; duration.Style.BackColor = Color.LightGray; duration.Value = ""; } else { value.Style.BackColor = Color.White; } value.ReadOnly = true; } }
public static bool IniciarDgvDefault(ref DataGridView dgvHorario, int comienzoHorario, int numeroFilas, string mensaje, Color ColorPrimario, Color ColorSecundario) { try { // Button a = new Button(); for (int i = 0; i < numeroFilas; i++) { DataGridViewTextBoxCell a = new DataGridViewTextBoxCell(); a.Style.BackColor = Color.Gray; dgvHorario.Rows.Add(new object[] { a, a, a, a, a, a, a, a }); dgvHorario.Rows[i].HeaderCell.Value = Convert.ToString(comienzoHorario + i) + ":00"; dgvHorario.Rows[i].Height = 25; } int temp = 0; foreach (DataGridViewRow row in dgvHorario.Rows) { foreach (DataGridViewCell boton in row.Cells) { boton.Value = mensaje; if (temp % 2 == 0) { boton.Style.BackColor = ColorPrimario; } else { boton.Style.BackColor = ColorSecundario; } } temp++; } return(true); } catch (Exception) { return(false); } }
private DataGridViewRow NewAlertRow(Alert alert) { var expanderCell = new DataGridViewImageCell(); var imageCell = new DataGridViewImageCell(); var appliesCell = new DataGridViewTextBoxCell(); var detailCell = new DataGridViewTextBoxCell(); var dateCell = new DataGridViewTextBoxCell(); var actionItems = GetAlertActionItems(alert); var actionCell = new DataGridViewDropDownSplitButtonCell(actionItems.ToArray()); var newRow = new DataGridViewRow { Tag = alert, MinimumHeight = DataGridViewDropDownSplitButtonCell.MIN_ROW_HEIGHT }; // Get the relevant image for the row depending on the type of the alert Image typeImage = alert is MessageAlert && ((MessageAlert)alert).Message.ShowOnGraphs ? Images.GetImage16For(((MessageAlert)alert).Message.Type) : Images.GetImage16For(alert.Priority); imageCell.Value = typeImage; // Set the detail cell content and expanding arrow if (expandedState.ContainsKey(alert.uuid)) { // show the expanded arrow and the body detail expanderCell.Value = Properties.Resources.expanded_triangle; detailCell.Value = String.Format("{0}\n\n{1}", alert.Title, alert.Description); } else { // show the expand arrow and just the title expanderCell.Value = Properties.Resources.contracted_triangle; detailCell.Value = alert.Title; } appliesCell.Value = alert.AppliesTo; dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true); newRow.Cells.AddRange(expanderCell, imageCell, detailCell, appliesCell, dateCell, actionCell); return(newRow); }
private void cbBranch_SelectedIndexChanged(object sender, EventArgs e) { if (cbBranch.SelectedIndex > 0) { objDb = new SQLDB(); DataTable dt = null; string[] sBranchCode = cbBranch.SelectedValue.ToString().Split('@'); string strCmd = " SELECT DISTINCT(PPM_WEF_DATE) FROM PRODUCT_PRICE_MASTER WHERE PPM_COMP_CODE='" + sBranchCode[2] + "' AND PPM_BRANCH_CODE='" + sBranchCode[0] + "'"; try { dt = objDb.ExecuteDataSet(strCmd).Tables[0]; if (dt.Rows.Count > 0) { gvProductPrice.Rows.Clear(); for (int iVar = 0; iVar < dt.Rows.Count; iVar++) { DataGridViewRow tempRow = new DataGridViewRow(); DataGridViewCell cellSNo = new DataGridViewTextBoxCell(); cellSNo.Value = (iVar + 1).ToString(); tempRow.Cells.Add(cellSNo); DataGridViewCell cellDate = new DataGridViewTextBoxCell(); cellDate.Value = Convert.ToDateTime(dt.Rows[iVar]["PPM_WEF_DATE"].ToString()).ToString("dd-MMM-yyyy").ToUpper(); tempRow.Cells.Add(cellDate); gvProductPrice.Rows.Add(tempRow); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objDb = null; dt = null; } } }
/// <summary> /// create a table for papers/создать таблицу для бумаг /// </summary> private void CreateTable() { _grid = DataGridFactory.GetDataGridView(DataGridViewSelectionMode.FullRowSelect, DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders); _grid.ScrollBars = ScrollBars.Vertical; DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell(); cell0.Style = _grid.DefaultCellStyle; DataGridViewColumn column0 = new DataGridViewColumn(); column0.CellTemplate = cell0; column0.HeaderText = OsLocalization.Data.Label2; column0.ReadOnly = true; column0.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _grid.Columns.Add(column0); DataGridViewColumn column1 = new DataGridViewColumn(); column1.CellTemplate = cell0; column1.HeaderText = OsLocalization.Data.Label3; column1.ReadOnly = true; column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _grid.Columns.Add(column1); DataGridViewCheckBoxColumn colum6 = new DataGridViewCheckBoxColumn(); //colum6.CellTemplate = cell0; colum6.HeaderText = OsLocalization.Trader.Label171; colum6.ReadOnly = false; colum6.Width = 50; _grid.Columns.Add(colum6); HostSecurity.Child = _grid; TextBoxSearchSec.Text = OsLocalization.Trader.Label174; TextBoxSearchSec.TextChanged += TextBoxSearchSec_TextChanged; }
private void hkcombo_SelectedIndexChanged(object sender, EventArgs e) { dsmhgrid.Rows.Clear(); string tt1 = namhoccombo.SelectedItem.ToString(); string tt2 = hockicomboo.SelectedItem.ToString(); string tt3 = ""; if (tt2 == "HK1") { tt3 = 1 + tt1; } else if (tt2 == "HK2") { tt3 = 2 + tt1; } int kq = int.Parse(tt3); HSB.loadhavehk(kq); foreach (var s in CTMonHoc.haveHK) { DataGridViewRow row = new DataGridViewRow(); DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Value = s.MaMon1; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = s.TenMon1; row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = hockicomboo.SelectedItem.ToString(); row.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = namhoccombo.SelectedItem.ToString(); row.Cells.Add(cell); dsmhgrid.Rows.Add(row); } }
public void CreateParamDataGrid() { _newGrid = DataGridFactory.GetDataGridView(DataGridViewSelectionMode.CellSelect, DataGridViewAutoSizeRowsMode.None); DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell(); cell0.Style = _newGrid.DefaultCellStyle; DataGridViewColumn colum0 = new DataGridViewColumn(); colum0.CellTemplate = cell0; colum0.HeaderText = OsLocalization.Market.GridColumn1; colum0.ReadOnly = true; colum0.Width = 200; _newGrid.Columns.Add(colum0); DataGridViewColumn colu = new DataGridViewColumn(); colu.CellTemplate = cell0; colu.HeaderText = OsLocalization.Market.GridColumn2; colu.ReadOnly = false; colu.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _newGrid.Columns.Add(colu); DataGridViewColumn colum1 = new DataGridViewColumn(); colum1.CellTemplate = cell0; colum1.HeaderText = @""; colum1.ReadOnly = true; colum1.Width = 100; _newGrid.Columns.Add(colum1); HostSettings.Child = _newGrid; _newGrid.CellValueChanged += _newGrid_CellValueChanged; _newGrid.Click += _newGrid_Click; }
public void GetHamali(DataTable Dt, int Type) { int intRow = 1; gvLicence.Rows.Clear(); for (int i = 0; i < Dt.Rows.Count; i++) { DataGridViewRow tempRow = new DataGridViewRow(); DataGridViewCell cellSLNO = new DataGridViewTextBoxCell(); cellSLNO.Value = intRow; tempRow.Cells.Add(cellSLNO); DataGridViewCell cellExamPass = new DataGridViewTextBoxCell(); cellExamPass.Value = Dt.Rows[i]["PM_BRAND_ID"]; tempRow.Cells.Add(cellExamPass); DataGridViewCell cellYearPass = new DataGridViewTextBoxCell(); cellYearPass.Value = Dt.Rows[i]["PM_PRODUCT_ID"]; tempRow.Cells.Add(cellYearPass); DataGridViewCell cellSubject = new DataGridViewTextBoxCell(); cellSubject.Value = Dt.Rows[i]["PM_PRODUCT_NAME"]; tempRow.Cells.Add(cellSubject); if (Type == 0) { DataGridViewCell cellV_G = new DataGridViewTextBoxCell(); cellV_G.Value = Dt.Rows[i]["SPHC_VtoG"]; tempRow.Cells.Add(cellV_G); DataGridViewCell cellV_V = new DataGridViewTextBoxCell(); cellV_V.Value = Dt.Rows[i]["SPHC_VtoV"]; tempRow.Cells.Add(cellV_V); DataGridViewCell cellG_V = new DataGridViewTextBoxCell(); cellG_V.Value = Dt.Rows[i]["SPHC_GtoV"]; tempRow.Cells.Add(cellG_V); } intRow = intRow + 1; gvLicence.Rows.Add(tempRow); } }
private void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { string y = ""; if (dataGridView2.Columns[e.ColumnIndex].Name == "结束时间") { if (dataGridView2.Rows[e.RowIndex].Cells["结束时间"].Value != null && dataGridView2.Rows[e.RowIndex].Cells["结束时间"].Value.ToString() != "") { y = "完成维修"; DataGridViewTextBoxCell bc = new DataGridViewTextBoxCell(); bc.Value = y; dataGridView2.Rows[e.RowIndex].Cells["button1"] = bc; } else if (dataGridView2.Rows[e.RowIndex].Cells["开始时间"].Value != null && dataGridView2.Rows[e.RowIndex].Cells["开始时间"].Value.ToString() != "") { y = "正在维修中..."; DataGridViewTextBoxCell bc = new DataGridViewTextBoxCell(); bc.Value = y; dataGridView2.Rows[e.RowIndex].Cells["button1"] = bc; } } //if (dataGridView2.Columns[e.ColumnIndex].Name == "开始时间") //{ // if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null&& dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() != "") // { // DataGridViewTextBoxCell bc = new DataGridViewTextBoxCell(); // bc.Value = "正在维修中..."; // dataGridView2.Rows[e.RowIndex].Cells["button1"] = bc; // } //} //if (dataGridView2.Columns[e.ColumnIndex].Name == "结束时间") //{ // if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null && dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() != "") // { // DataGridViewTextBoxCell bc = new DataGridViewTextBoxCell(); // bc.Value = "完成维修"; // dataGridView2.Rows[e.RowIndex].Cells["button1"] = bc; // } //} }
private void CreateGridIndicators() { //_series = CreateSeries("Ma", Color.DodgerBlue, IndicatorChartPaintType.Line, false); _gridIndicators = DataGridFactory.GetDataGridView(DataGridViewSelectionMode.CellSelect, DataGridViewAutoSizeRowsMode.None); DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell(); cell0.Style = _gridIndicators.DefaultCellStyle; DataGridViewColumn column0 = new DataGridViewColumn(); column0.CellTemplate = cell0; column0.HeaderText = "Name"; column0.ReadOnly = true; column0.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _gridIndicators.Columns.Add(column0); DataGridViewColumn column1 = new DataGridViewColumn(); column1.CellTemplate = cell0; column1.HeaderText = "Type"; column1.ReadOnly = true; column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _gridIndicators.Columns.Add(column1); DataGridViewColumn column2 = new DataGridViewColumn(); column2.CellTemplate = cell0; column2.ReadOnly = false; column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _gridIndicators.Columns.Add(column2); _gridIndicators.Rows.Add(null, null); HostIndicators.Child = _gridIndicators; _gridIndicators.Click += _gridIndicators_Click; }
private void CreateGrid() { GridViewBox = DataGridFactory.GetDataGridView(DataGridViewSelectionMode.FullRowSelect, DataGridViewAutoSizeRowsMode.AllCells); DataGridViewTextBoxCell cell0 = new DataGridViewTextBoxCell(); cell0.Style = GridViewBox.DefaultCellStyle; DataGridViewColumn column0 = new DataGridViewColumn(); column0.CellTemplate = cell0; column0.HeaderText = OsLocalization.Alerts.GridHeader0; column0.ReadOnly = true; column0.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; //column0.Width = 150; GridViewBox.Columns.Add(column0); DataGridViewColumn column = new DataGridViewColumn(); column.CellTemplate = cell0; column.HeaderText = OsLocalization.Alerts.GridHeader1; column.ReadOnly = true; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; // column.Width = 150; GridViewBox.Columns.Add(column); DataGridViewColumn column1 = new DataGridViewColumn(); column1.CellTemplate = cell0; column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; column1.ReadOnly = true; // column1.Width = 150; column1.HeaderText = OsLocalization.Alerts.GridHeader2; GridViewBox.Columns.Add(column1); GridViewBox.Rows.Add(null, null); GridViewBox.Click += GridViewBox_Click; GridViewBox.DoubleClick += GridViewBox_DoubleClick; }
private void M_SceneControl_ObjectAdded(object sender, ObjectAddedEventArgs e) { Recordset objRt = null; try { if (chkTheme.SelectedItem == null) { m_Application.MessageBox.Show(Message); return; } dg_Data.Rows.Clear(); Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset; objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Static); if (objRt.SeekID(e.ID)) { DataGridViewRow row = new DataGridViewRow(); row.HeaderCell.Value = objRt.GetID().ToString(); for (int j = 0; j < dg_Data.ColumnCount; j++) { DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell(); textBoxCell.Value = Convert.ToString(objRt.GetFieldValue(dg_Data.Columns[j].Name)); row.Cells.Add(textBoxCell); } dg_Data.Rows.Add(row); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
private void dgWhere_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (dgWhere.Columns[dgWhere.CurrentCell.ColumnIndex].Name != "fields") { return; } if (dgWhere.Rows[e.RowIndex].Cells["fields"].Value == null) { return; } String id = dgWhere.Rows[e.RowIndex].Cells["fields"].Value.ToString(); String sprName = null; foreach (DataRow row in dtListField.Select("id = '" + id + "'")) { sprName = row["spr"].ToString(); } //MessageBox.Show(sprName); if (sprName == String.Empty) { DataGridViewTextBoxCell tbcell = new DataGridViewTextBoxCell(); dgWhere.Rows[e.RowIndex].Cells["value"] = tbcell; dgWhere.Rows[e.RowIndex].Cells["conditions"].ReadOnly = false; return; } SprDbConnect sprCon = new SprDbConnect(sprName); DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); cell.DataSource = sprCon.GetDataTable(sprName); cell.ValueMember = "id"; cell.DisplayMember = "name"; cell.DropDownWidth = 100; cell.MaxDropDownItems = 7; dgWhere.Rows[e.RowIndex].Cells["value"] = cell; dgWhere.Rows[e.RowIndex].Cells["conditions"].Value = 1; dgWhere.Rows[e.RowIndex].Cells["conditions"].ReadOnly = true; }
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;*/ }
void dd2_FormClosing(object sender, FormClosingEventArgs e) { InvoiceControlTankStockAdd ctrl = (InvoiceControlTankStockAdd)sender; if (string.IsNullOrEmpty(ctrl.TankNumber)) return; int i; i = dataGridView1.Rows.Add(new DataGridViewRow()); DataGridViewCell cell1 = new DataGridViewTextBoxCell(); cell1.Value = "צובר "+ctrl.tankSize+" גלון מספר "+ctrl.TankNumber+""; dataGridView1.Rows[i].Cells["dtclmnTitle"] = cell1; invoiceitem newrow = new invoiceitem(); newrow.title = "צובר " + ctrl.tankSize + " גלון מספר " + ctrl.TankNumber + ""; 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; _currentinvoiceitems.Add(newrow); if (ctrl._Type == "tank") { if (null == _currentinvoice) { updateTankStock(ctrl._Typeid, txtinvoiceid.Text); } else { updateTankStock(ctrl._Typeid, _currentinvoice.invoiceNumber); } havetank = true; } }