public DataGridView DatesAvailableBox(DataGridView data, Member selectedMember) { data.Rows.Clear(); data.Refresh(); data.Columns["Date"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; List<UnavailableDate> udates = manager.UnavailableDateByMemberId(selectedMember.Id); TimeSpan startSpan = new TimeSpan(21, 0, 0, 0); TimeSpan endSpan = new TimeSpan(120, 0, 0, 0); DateTime start = DateTime.Now - startSpan; DateTime end = DateTime.Now + endSpan; string dayOfWeekMeeting = selectedMember.Congregation.WeekMeetingDay; string dayOfPublicMeeting = selectedMember.Congregation.PublicMeetingDay; bool available = true; foreach (DateTime day in manager.EachDayLoop(start, end)) { available = true; if (udates.Any(z => z.DateUnavailable == day) || (selectedMember.IsAvailablePublicMeeting == false && day.DayOfWeek.ToString() == dayOfPublicMeeting) || (selectedMember.IsAvailableWeekMeeting == false && day.DayOfWeek.ToString() == dayOfWeekMeeting)) { available = false; } if (Convert.ToString(day.DayOfWeek) == dayOfWeekMeeting || Convert.ToString(day.DayOfWeek) == dayOfPublicMeeting) { string dd = day.DayOfWeek + ", " + day.ToShortDateString(); data.Rows.Add(null, available, dd); } } return data; }
public DataGridView CurrentMembersBox(DataGridView data, int congregationId) { List<Member> mem = manager.MembersByCongregationId(congregationId); data.Rows.Clear(); data.Refresh(); data.AutoGenerateColumns = false; data.ColumnCount = 2; data.Columns[0].Name = "Id"; data.Columns[0].Visible = false; data.Columns[1].Name = "Member"; data.Columns[1].Visible = true; data.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; foreach (Member m in mem) { string[] row = new string[2]; if (m.PreferredName == null || m.PreferredName == "") { row = new string[2] { m.Id.ToString(), m.FirstName + " " + m.LastName }; } else { row = new string[2] { m.Id.ToString(), Convert.ToString(m.PreferredName) }; } data.Rows.Add(row); } return data; }
private void CreateTab(SharpMap.Data.FeatureDataTable featureDataTable) { this.tabControl1.TabPages.Add(featureDataTable.TableName, featureDataTable.TableName); System.Windows.Forms.DataGridView dv = new DataGridView(); dv.AllowUserToAddRows = false; dv.AllowUserToDeleteRows = false; dv.AllowUserToOrderColumns = true; dv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dv.Font = this.Font; dv.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dv_DataBindingComplete); dv.Dock = System.Windows.Forms.DockStyle.Fill; dv.Location = new System.Drawing.Point(3, 3); dv.Name = "dvSelection"; dv.ReadOnly = true; dv.Size = new System.Drawing.Size(278, 234); dv.TabIndex = 1; dv.VirtualMode = true; dv.CellValueNeeded += new DataGridViewCellValueEventHandler(dv_CellValueNeeded); dv.CellDoubleClick += new DataGridViewCellEventHandler(dv_CellDoubleClick); dv.CellClick += new DataGridViewCellEventHandler(dv_CellClick); dv.AllowUserToAddRows = false; dv.AllowUserToDeleteRows = false; dv.AllowUserToOrderColumns = true; dv.AllowUserToResizeColumns = true; dv.AllowUserToResizeRows = true; dv.MultiSelect = false; this.tabControl1.TabPages[featureDataTable.TableName].Controls.Add(dv); //dv.DataSource = featureDataTable; DataSources[featureDataTable.TableName] = featureDataTable; SetupRowsAndColumns(dv, featureDataTable); dv.Refresh(); }
public static void SetRowsVisibilityByScore(DataGridView gridView, double threshold, bool visState) { Console.WriteLine("Hiding"); gridView.SuspendLayout(); CurrencyManager currencyManager = gridView.BindingContext[gridView.DataSource] as CurrencyManager; currencyManager.SuspendBinding(); int timeElapsed = Environment.TickCount; foreach(DataGridViewRow row in gridView.Rows) { int timeTick = Environment.TickCount; Console.WriteLine("Toggling row {0} - {1}", row, timeTick - timeElapsed); timeElapsed = timeTick; try { double ms2Score = (double)row.Cells.GetCellValueFromColumnHeader("MS2 Score"); if (ms2Score < threshold) { row.Visible = visState; } } catch { Console.WriteLine(row); //row.Visible = false; } } currencyManager.ResumeBinding(); gridView.ResumeLayout(); gridView.Refresh(); }
private DataGridView SetupDataGridView() { var dg = new DataGridView(); ComicList = new BindingList<ComicLineItem>(); ComicList.Add(new ComicLineItem(){ ComicName = "Test" }); dg.DataSource = ComicList; dg.Refresh(); return dg; }
private void CalcularPrecioHabitaciones(DataGridView dataGridView) { foreach (Habitacion habitacion in (List<Habitacion>)dataGridView.DataSource) { habitacion.cantidadPersonas = RepositorioHabitacion.Instance.CantidadPersonasParaHabitacion(habitacion); habitacion.precio = (/*((Regimen)this.RegimenDataGrid.CurrentRow.DataBoundItem).precio*/ (this.RegimenParaCalculo()).precio * habitacion.cantidadPersonas) + ((Hotel)hotelComboBox.SelectedItem).recarga; } dataGridView.Refresh(); }
public void Delete(DataGridView ddv) { int indexid = 0; indexid = ddv.CurrentRow.Index; string sql = ""; sql = "delete from T_CustomerInf where CustID='" + ddv.Rows[indexid].Cells[0].Value.ToString() + "'"; try { (new SqlDBConnect()).ExecuteNonQuery(sql); //ddv.Rows.RemoveAt(ddv.CurrentRow.Index); ddv.Refresh(); } catch { MessageBox.Show("数据更新失败或存在外码约束!"); } finally { } }
public static void ConfiguraDataGridView(DataGridView dg, string nome) { DataTable dt = new DataTable(); ItemEstoqueControl itemEstoque = new ItemEstoqueControl(); dt = itemEstoque.Pesquisar(nome); //popula o datagrid retornado dg.RowsDefaultCellStyle.BackColor = Color.White; dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue; dg.EnableHeadersVisualStyles = true; dg.DataSource = dt; //formata as colunas do datagrid dg.Columns["ID_ITEM"].HeaderText = "Reg. nº"; //Nome coluna dg.Columns["ID_ITEM"].Width = 80; //largura coluna dg.Columns["ID_ITEM"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["ID_ITEM"].ToolTipText = "Número do Registro"; dg.Columns["ID_ITEM"].DefaultCellStyle.Format = "0000000"; dg.Columns["ID_ITEM"].Visible = true; dg.Columns["DESCRICAO"].HeaderText = "Descrição"; //Nome coluna dg.Columns["DESCRICAO"].Width = 300; //largura coluna dg.Columns["DESCRICAO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["DESCRICAO"].ToolTipText = "Descrição"; dg.Columns["DESCRICAO"].Visible = true; dg.Columns["UNIDADE_MEDIDA"].HeaderText = "Unidade de Medida"; //Nome coluna dg.Columns["UNIDADE_MEDIDA"].Width = 150; //largura coluna dg.Columns["UNIDADE_MEDIDA"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["UNIDADE_MEDIDA"].ToolTipText = "Unidade de Medida"; dg.Columns["UNIDADE_MEDIDA"].Visible = true; dg.Columns["ESTOQUE_MINIMO"].HeaderText = "Estoque Minimo"; //Nome coluna dg.Columns["ESTOQUE_MINIMO"].Width = 150; //largura coluna dg.Columns["ESTOQUE_MINIMO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["ESTOQUE_MINIMO"].ToolTipText = "Estoque Minimo"; dg.Columns["ESTOQUE_MINIMO"].Visible = true; dg.Refresh(); //-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* return; }
public void Delete(DataGridView ddv) { SqlDBConnect sqldb = new SqlDBConnect(); int indexid = 0; indexid = ddv.CurrentRow.Index; string sql = ""; sql = "delete from T_CustomerCall where BargId='" + ddv.Rows[indexid].Cells["合同编号"].Value.ToString() + "'"; try { sqldb.ExecuteNonQuery(sql); //MessageBox.Show("数据更新成功!"); ddv.Rows.RemoveAt(ddv.CurrentRow.Index); ddv.Refresh(); } catch { MessageBox.Show("数据更新失败或存在外码约束!"); } finally { } }
public static void ConvertDg2Bmp( DataGridView dg, string sFilePath) { dg.Refresh(); dg.Select(); Graphics g = dg.CreateGraphics(); var ibitMap = new Bitmap ( dg.ClientSize.Width, dg.ClientSize.Height, g); Graphics iBitMapGr = Graphics.FromImage(ibitMap); IntPtr iBitMapHdc = iBitMapGr.GetHdc(); IntPtr meHdc = g.GetHdc(); BitBlt ( iBitMapHdc, 0, 0, dg.ClientSize.Width, dg.ClientSize.Height, meHdc, 0, 0, Src); g.ReleaseHdc(meHdc); iBitMapGr.ReleaseHdc(iBitMapHdc); if (sFilePath == "") { return; } ibitMap.Save ( sFilePath, ImageFormat.Bmp); }
public static DataGridView CopyDataGridViewPrintSelected(DataGridView source) { DataGridView copy = new DataGridView(); try { if (copy.Columns.Count == 0) { foreach (DataGridViewColumn column in source.Columns) { copy.Columns.Add(column.Clone() as DataGridViewColumn); } } var row = new DataGridViewRow(); for (int i = 0; i < source.Rows.Count; i++) { row = (DataGridViewRow)source.Rows[i].Clone(); if ((bool)source.Rows[i].Cells["Print"].Value == true) { var columnIndex = 0; foreach (DataGridViewCell cell in source.Rows[i].Cells) { row.Cells[columnIndex].Value = cell.Value; columnIndex++; } copy.Rows.Add(row); } } copy.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return copy; }
private void СolorizeByPriorities(System.Windows.Forms.DataGridView dataGridView) { System.Collections.IList list = dataGridView.Rows; foreach (var item in list) { DataGridViewRow row = (DataGridViewRow)item; var priorityCell = row.Cells["Приоритет"]; //var priorityCell = dataGridView. if (priorityCell.Value != null) { if (priorityCell.Value.ToString() == Note.Priorities.High.ToString()) { foreach (DataGridViewCell cell in priorityCell.OwningRow.Cells) { cell.Style.BackColor = Color.Red; } } if (priorityCell.Value.ToString() == Note.Priorities.Medium.ToString()) { foreach (DataGridViewCell cell in priorityCell.OwningRow.Cells) { cell.Style.BackColor = Color.Yellow; } } if (priorityCell.Value.ToString() == Note.Priorities.Low.ToString()) { foreach (DataGridViewCell cell in priorityCell.OwningRow.Cells) { cell.Style.BackColor = Color.DarkGray; } } } } dataGridView.Refresh(); this.Update(); }
public void Delete(DataGridView ddv) { SqlDBConnect sqldb = new SqlDBConnect(); int indexid = 0; indexid = ddv.CurrentRow.Index; string sql = ""; sql = "delete from T_CustContacts where CName='" + ddv.Rows[indexid].Cells["联系姓名"].Value.ToString().Trim () + "'"; try { sqldb.ExecuteNonQuery(sql); MessageBox.Show("删除成功!"); ddv.Rows.RemoveAt(ddv.CurrentRow.Index); ddv.Refresh(); } catch { MessageBox.Show("更新失败!"); } finally { } }
//updating a table public void updateTable(DataGridView dataGridView1, string selectcommand, string tableName, int maxHeight) { SqlCeDataAdapter adapter = new SqlCeDataAdapter(); SqlCeCommand cmd = Form1.con.CreateCommand(); DataSet ds = new DataSet(); cmd.CommandText = selectcommand; adapter.SelectCommand = cmd; adapter.Fill(ds, tableName); int row = ds.Tables[tableName].Rows.Count - 1; int dgrow = dataGridView1.Rows.Count - 2; //checkign if a row was deleted while (dgrow >= row + 1) { dataGridView1.Rows.RemoveAt(dgrow); dgrow--; } //checkign if a row was added while (dgrow < row) { dataGridView1.Rows.Add(); dgrow++; } //updating datas int cellnr = dataGridView1.Rows[0].Cells.Count; for (int r = 0; r <= row; r++) { for (int i = 0; i < cellnr; ++i) { dataGridView1.Rows[r].Cells[i].Value = ds.Tables[tableName].Rows[r].ItemArray[i]; } } //set automatic height to datagridview dataGridView1.Height = setAutomaticHeight(dataGridView1.Columns[0].HeaderCell.Size.Height, dataGridView1.Rows[0].Height, dataGridView1.Rows.Count, maxHeight); dataGridView1.Refresh(); }
public void DisplayTable(DataGridView dgrid) { var provider = dgrid.DataSource as DataTable; if (provider.Columns["StopLVL"] == null) { provider.Columns.Add(new DataColumn("StopLVL")); provider.Columns.Add(new DataColumn("RevLVL")); provider.Columns.Add(new DataColumn("ZIM")); provider.Columns[5].ReadOnly = true; provider.Columns[6].ReadOnly = true; provider.Columns[7].ReadOnly = true; } string entrieTrSum = FormatNumber(Math.Round(Strategyperformance.EntireTradesSum, 2)); string profitTrSum = FormatNumber(Math.Round(Strategyperformance.ProfitTradesSum, 2)); string losTrSum = FormatNumber(Math.Round(Strategyperformance.LossTradesSum, 2)); string avgTr = FormatNumber(Math.Round(Strategyperformance.AverageTrade, 2)); var values = new ArrayList { Symbol, MinDt.ToString(DateFormatsManager.CurrentShortDateFormat + " HH:mm:ss"), MaxDt.ToString(DateFormatsManager.CurrentShortDateFormat + " HH:mm:ss"), entrieTrSum, //profitTrSum, //String.Format("{0:0 000.00}",Math.Round(Strategyperformance.ProfitTradesSum, 2)), //losTrSum, //String.Format("{0:0 000.00}", Math.Round(Strategyperformance.LossTradesSum, 2)), //Math.Round(Strategyperformance.Profitability, 2), //Math.Round(Strategyperformance.ProfitFactor, 2), //avgTr, //String.Format("{0:0 000.00}",Math.Round(Strategyperformance.AverageTrade, 4)), //Strategyperformance.EntireTradesCount, //Strategyperformance.ProfitTradesCount, //Strategyperformance.LossTradesCount, Strategyperformance.Reversals, Strategy.AdditionalParameters[7].Value, Strategy.AdditionalParameters[8].Value, Strategy.AdditionalParameters[5].Value }; if (provider != null) provider.Rows.Add(values.ToArray()); values.Clear(); try { MethodInvoker action = delegate { dgrid.DataSource = null; dgrid.DataSource = provider; dgrid.Columns[1].FillWeight = dgrid.Columns[2].FillWeight = 180; dgrid.Refresh(); }; dgrid.Invoke(action); } catch (Exception) { } }
private List<Control> GetControls(GridField gridField, Size canvasSize) { DataGridView gridView = new DataGridView(); gridView.AutoGenerateColumns = false; gridView.Width = 160; gridView.Height = 150; SetControlProperties(gridView, gridField, canvasSize); gridView.TabStop = false; gridView.BorderStyle = borderStyle; gridView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; gridView.EnableHeadersVisualStyles = true; gridView.ColumnHeadersDefaultCellStyle.Font = gridField.PromptFont; RectangleF rectF = new RectangleF(gridView.Left, gridView.Top, gridView.Width, ((float)1.75 * (int)gridField.PromptFont.Size)); gridView.Top = WinUtil.GetControlTop(gridField, canvasSize.Height); List<GridColumnBase> columns = new List<GridColumnBase>(gridField.Columns); columns.Sort(Util.SortByPosition); foreach (GridColumnBase gridCol in columns) { if (gridCol is TableBasedDropDownColumn) { DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn(); try { comboBoxColumn.MinimumWidth = 25; comboBoxColumn.Name = gridCol.Name; comboBoxColumn.DataPropertyName = gridCol.Name; comboBoxColumn.HeaderText = gridCol.Text; comboBoxColumn.ReadOnly = gridCol.IsReadOnly; comboBoxColumn.Width = gridCol.Width; comboBoxColumn.FlatStyle = FlatStyle.Flat; comboBoxColumn.Tag = gridCol; string displayMember = ((TableBasedDropDownColumn)gridCol).TextColumnName.Trim(); if (gridCol is YesNoColumn) { DataTable dataTable = new DataTable(); dataTable.Columns.Add("name", typeof(string)); dataTable.Columns.Add("value", typeof(byte)); DataRow dataRow; dataRow = dataTable.NewRow(); dataRow["name"] = config.Settings.RepresentationOfYes; dataRow["value"] = Constants.YES; dataTable.Rows.Add(dataRow); dataRow = dataTable.NewRow(); dataRow["name"] = config.Settings.RepresentationOfNo; dataRow["value"] = Constants.NO; dataTable.Rows.Add(dataRow); dataRow = dataTable.NewRow(); dataRow["name"] = config.Settings.RepresentationOfMissing; dataRow["value"] = DBNull.Value; dataTable.Rows.Add(dataRow); comboBoxColumn.ValueMember = "value"; comboBoxColumn.DisplayMember = "name"; comboBoxColumn.DataSource = dataTable; } else { if (!displayMember.Equals(string.Empty)) { comboBoxColumn.DisplayMember = displayMember; comboBoxColumn.ValueMember = displayMember; if (((TableBasedDropDownColumn)gridCol).ShouldSort) { DataTable dataTable = ((TableBasedDropDownColumn)gridCol).GetSourceData(); dataTable.Select(null, dataTable.Columns[0].ColumnName); comboBoxColumn.DataSource = dataTable; } else { comboBoxColumn.DataSource = ((TableBasedDropDownColumn)gridCol).GetSourceData(); } } } } catch (InvalidOperationException ioEx) { MsgBox.ShowException(ioEx); } gridView.Columns.Add(comboBoxColumn); } else if (gridCol is PatternableColumn) { bool isTimeBasedColumn = false; if (gridCol is DateColumn || gridCol is DateTimeColumn || gridCol is TimeColumn) { isTimeBasedColumn = true; } MaskedTextBoxColumn maskedTextBoxColumn = new MaskedTextBoxColumn(); maskedTextBoxColumn.MinimumWidth = 25; if (isTimeBasedColumn == false) { maskedTextBoxColumn.Mask = AppData.Instance.DataPatternsDataTable.GetMaskByPattern(((PatternableColumn)gridCol).Pattern); } maskedTextBoxColumn.HidePromptOnLeave = DataGridViewTriState.True; maskedTextBoxColumn.Name = gridCol.Name; maskedTextBoxColumn.HeaderText = gridCol.Text; maskedTextBoxColumn.ReadOnly = gridCol.IsReadOnly; maskedTextBoxColumn.Width = gridCol.Width; maskedTextBoxColumn.GridColumn = ((PatternableColumn)gridCol); maskedTextBoxColumn.DataPropertyName = gridCol.Name; if (isTimeBasedColumn == false) { maskedTextBoxColumn.DefaultCellStyle.Format = AppData.Instance.DataPatternsDataTable.GetExpressionByMask(maskedTextBoxColumn.Mask, ((PatternableColumn)gridCol).Pattern); } System.Globalization.DateTimeFormatInfo formatInfo = System.Globalization.DateTimeFormatInfo.CurrentInfo; if (gridCol is DateColumn) { ((System.Windows.Forms.DataGridViewColumn)(maskedTextBoxColumn)).DefaultCellStyle.Format = formatInfo.ShortDatePattern; } else if (gridCol is TimeColumn) { ((System.Windows.Forms.DataGridViewColumn)(maskedTextBoxColumn)).DefaultCellStyle.Format = formatInfo.ShortTimePattern; } gridView.Columns.Add(maskedTextBoxColumn); } else if (gridCol is CheckboxColumn) { DataGridViewColumn column = new DataGridViewCheckBoxColumn(); try { column.MinimumWidth = 25; column.Name = gridCol.Name; column.HeaderText = gridCol.Text; column.ReadOnly = gridCol.IsReadOnly; column.DataPropertyName = gridCol.Name; column.Width = gridCol.Width; } catch (InvalidOperationException ioEx) { MsgBox.ShowException(ioEx); } gridView.Columns.Add(column); } else { DataGridViewTextBoxColumn textBoxColumn = new DataGridViewTextBoxColumn(); try { textBoxColumn.MinimumWidth = 25; textBoxColumn.Name = gridCol.Name; textBoxColumn.HeaderText = gridCol.Text; textBoxColumn.ReadOnly = gridCol.IsReadOnly; textBoxColumn.DataPropertyName = gridCol.Name; if (gridCol is PredefinedColumn) { textBoxColumn.ReadOnly = true; } textBoxColumn.Width = gridCol.Width; if (gridCol is TextColumn) { textBoxColumn.MaxInputLength = ((TextColumn)gridCol).Size; } } catch (InvalidOperationException ioEx) { MsgBox.ShowException(ioEx); } gridView.Columns.Add(textBoxColumn); } } try { gridView.Columns[ColumnNames.REC_STATUS].ReadOnly = true; gridView.Columns[ColumnNames.REC_STATUS].Visible = false; gridView.Columns[ColumnNames.UNIQUE_ROW_ID].ReadOnly = true; gridView.Columns[ColumnNames.UNIQUE_ROW_ID].Visible = false; gridView.Columns[ColumnNames.FOREIGN_KEY].ReadOnly = true; gridView.Columns[ColumnNames.FOREIGN_KEY].Visible = false; if (gridView.Columns.Contains(ColumnNames.GLOBAL_RECORD_ID)) { gridView.Columns[ColumnNames.GLOBAL_RECORD_ID].ReadOnly = true; gridView.Columns[ColumnNames.GLOBAL_RECORD_ID].Visible = false; } gridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect; gridView.Tag = gridField; gridView.BackgroundColor = Color.White; gridView.RowHeadersVisible = false; gridView.MultiSelect = true; ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem deleteRowStripMenuItem = new ToolStripMenuItem(); contextMenuStrip.SuspendLayout(); deleteRowStripMenuItem.Name = "deleteRow"; deleteRowStripMenuItem.Text = "Delete Row"; deleteRowStripMenuItem.Image = global::Epi.Enter.Properties.Resources.delete_icon; deleteRowStripMenuItem.ImageTransparentColor = Color.White; deleteRowStripMenuItem.Tag = gridView; deleteRowStripMenuItem.Click += new EventHandler(deleteRowStripMenuItem_Click); contextMenuStrip.Items.Add(deleteRowStripMenuItem); contextMenuStrip.ResumeLayout(); gridView.ContextMenuStrip = contextMenuStrip; gridView.Refresh(); } catch (InvalidOperationException ioEx) { MsgBox.ShowException(ioEx); } catch (Exception ex) { MsgBox.ShowException(ex); } TransparentLabel prompt = GetPrompt(gridView, gridField, canvasSize); List<Control> controls = new List<Control>(); controls.Add(prompt); controls.Add(gridView); if (!fieldControls.ContainsKey(gridField)) { fieldControls.Add(gridField, controls); } return controls; }
private void LoadFilePatterns(FilePatternList Patterns, DataGridView Destination) { foreach (FilePattern FP in Patterns) { int RowIndex = Destination.Rows.Add(); Destination[0, RowIndex].Value = FP.Pattern; Destination[1, RowIndex].Value = (FP.IsValid ? "OK" : "Invalid file pattern"); } Destination.ClearSelection(); Destination.Refresh(); }
public static void llenarDataGrid(DataGridView dg, SqlConnection conn, SqlCommand cmd) { SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataTable tabla = new DataTable(); conn.Open(); da.Fill(tabla); conn.Close(); dg.DataSource = tabla; dg.Refresh(); }
public static void limpiarDataGrid(DataGridView dg) { dg.DataSource = null; dg.Rows.Clear(); dg.Refresh(); }
// ================================================================================= // Forcing a DataGridview display update // Ugly hack if you ask me, but MS didn't give us any other reliable way... private void Update_GridView(DataGridView Grid) { Grid.CommitEdit(DataGridViewDataErrorContexts.Commit); BindingSource bs = new BindingSource(); // create a BindingSource bs.DataSource = Grid.DataSource; // copy jobdata to bs DataTable dat = (DataTable)(bs.DataSource); // make a datatable from bs Grid.DataSource = dat; // and copy datatable data to jobdata, forcing redraw Grid.RefreshEdit(); Grid.Refresh(); }
private void OrganiseGrid() { try { dataGridSearch.Visible = false; dgvSearch = dataGridSearch; dgv = dataGridView; dtLogger.Columns.Add("Message", typeof(string)); dtLogger.Columns.Add("Logged", typeof(string)); dtLogger.Columns.Add("Level", typeof(string)); dtLogger.Columns.Add("User", typeof(string)); dtSearch.Columns.Add("Message", typeof(string)); dtSearch.Columns.Add("Logged", typeof(string)); dtSearch.Columns.Add("Level", typeof(string)); dtSearch.Columns.Add("User", typeof(string)); dtLogger.Rows.Clear(); dtSearch.Rows.Clear(); dgv.Refresh(); } catch { } }
/// <summary> /// Made reduce amount of code typed. /// </summary> /// <param name="dgv">takes in the datagridview you would like to update.</param> /// <param name="dv">I really have no idea lol</param> private void Update_DGV(DataGridView dgv, DataView dv) { dgv.DataSource = dv; dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv.Refresh(); }
public void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView) { int rowCount = gridView.RowCount; int currLine = gridView.CurrentCellAddress.Y; int currFirstLine = gridView.FirstDisplayedScrollingRowIndex; gridView.Columns.Clear(); DataGridViewTextBoxColumn markerColumn = new DataGridViewTextBoxColumn(); markerColumn.HeaderText = ""; markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; markerColumn.Resizable = DataGridViewTriState.False; markerColumn.DividerWidth = 1; markerColumn.ReadOnly = true; markerColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip; gridView.Columns.Add(markerColumn); DataGridViewTextBoxColumn lineNumberColumn = new DataGridViewTextBoxColumn(); lineNumberColumn.HeaderText = "Line"; lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; lineNumberColumn.Resizable = DataGridViewTriState.NotSet; lineNumberColumn.DividerWidth = 1; lineNumberColumn.ReadOnly = true; lineNumberColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip; gridView.Columns.Add(lineNumberColumn); foreach (string colName in columnizer.GetColumnNames()) { DataGridViewColumn titleColumn = new LogTextColumn(); titleColumn.HeaderText = colName; titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; titleColumn.Resizable = DataGridViewTriState.NotSet; titleColumn.DividerWidth = 1; titleColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip; gridView.Columns.Add(titleColumn); } columnNamesLabel.Text = CalculateColumnNames(_filterParams); gridView.RowCount = rowCount; if (currLine != -1) { gridView.CurrentCell = gridView.Rows[currLine].Cells[0]; } if (currFirstLine != -1) { gridView.FirstDisplayedScrollingRowIndex = currFirstLine; } gridView.Refresh(); AutoResizeColumns(gridView); ApplyFrozenState(gridView); }
private void TabParserLoad(string tabName, string parserType) { parserTabDataGridView.ColumnCount = 1; parserTabDataGridView.Rows.Clear(); parserTabDataGridView.Refresh(); parserTabDataGridView.ColumnHeadersVisible = false; parserTabDataGridView.Parent = tabControlParsers.TabPages[tabName]; var parserName = tabName.Replace("ParserTab", string.Empty); var filteredParser = parsers.Where(p => p.type == parserType && p.name == parserName).ToList(); var filter = $"key_id = {keyId} and parser_id in ({string.Join(", ", filteredParser.Select(x => x.id))})"; IEnumerable <object> data = null; switch (parserType) { case Parsers.type_texts: data = new TextsHelper().Select(dbName, filter).Select(x => new string[] { x.text, x.spin, x.url }); if (data != null && data.Any()) { parserTabDataGridView.ColumnHeadersVisible = true; parserTabDataGridView.ColumnCount = 3; parserTabDataGridView.Columns[0].Name = "text"; parserTabDataGridView.Columns[1].Name = "spin"; parserTabDataGridView.Columns[2].Name = "url"; foreach (string[] item in data) { parserTabDataGridView.Rows.Add(item); } } break; case Parsers.type_images: DataGridViewRow row1 = new DataGridViewRow(); data = new ImagesHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_videos: data = new VideosHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_snippets: data = new SnippetsHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_suggests: data = new SuggestsHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; } if (parserTabDataGridView.RowCount == 0 && data != null) { foreach (var item in data) { parserTabDataGridView.Rows.Add(item); } } }
void ApplyDataGridViewPrefs(DataGridView dataGridView, Preferences prefs) { if (dataGridView.Columns.Count > 1) { if (prefs.setLastColumnWidth) { dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth; } else { // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions). dataGridView.FirstDisplayedScrollingColumnIndex = 0; dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5; // default } } if (dataGridView.RowCount > 0) { dataGridView.UpdateRowHeightInfo(0, true); } dataGridView.Invalidate(); dataGridView.Refresh(); AutoResizeColumns(dataGridView); }
public override void Pesquisar(DataGridView dg, string nome) { ComprasControl compras = new ComprasControl(); pesquisa.DataSource = compras.getCompras(); dg.DataSource = pesquisa; if (pesquisa.Count <= 0) //trata o caso q a busca é vazia. evita q os cabeçalhos sumam. { return; } //popula o datagrid retornado dg.RowsDefaultCellStyle.BackColor = Color.White; dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue; dg.EnableHeadersVisualStyles = true; //formata as colunas do datagrid dg.Columns["Id"].HeaderText = "Reg. nº"; //Nome coluna dg.Columns["Id"].Width = 78; //largura coluna dg.Columns["Id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Id"].ToolTipText = "Número do Registro"; dg.Columns["Id"].DefaultCellStyle.Format = "0000000"; dg.Columns["Id"].Visible = true; dg.Columns["Codigo"].HeaderText = "Código"; //Nome coluna dg.Columns["Codigo"].Width = 100; //largura coluna dg.Columns["Codigo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Codigo"].ToolTipText = "Codigo do Produto"; dg.Columns["Codigo"].Visible = true; dg.Columns["NomeFornecedor"].HeaderText = "Descrição"; //Nome coluna dg.Columns["NomeFornecedor"].Width = 300; //largura coluna dg.Columns["NomeFornecedor"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["NomeFornecedor"].ToolTipText = "Descrição do Produto"; dg.Columns["NomeFornecedor"].Visible = true; dg.Columns["PrevisaoEntrega"].HeaderText = "Descrição"; //Nome coluna dg.Columns["PrevisaoEntrega"].Width = 445; //largura coluna dg.Columns["PrevisaoEntrega"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["PrevisaoEntrega"].ToolTipText = "Descrição do Produto"; dg.Columns["PrevisaoEntrega"].Visible = true; dg.Refresh(); }
//, ref BindingSource bsPositions, ref BindingSource bsBadges public void Populate(ref DataGridView DataGridView, ref BindingSource bs) { noOfRec = 0; //dssx.Dispose(); lbl_NoRec.Text = " songs."; bs.DataSource = null; dssx.Dispose(); //MessageBox.Show("zero " + noOfRec.ToString() + SearchCmd); //DB_Path = "../../../../tmp\\Files.accdb;"; using (OleDbConnection cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + DB_Path)) { OleDbDataAdapter da = new OleDbDataAdapter(SearchCmd, cn); //MessageBox.Show("pop" + noOfRec.ToString() + SearchCmd); dssx.Clear(); try { da.Fill(dssx, "Main"); } catch (Exception ex) { MessageBox.Show(ex.Message, MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("-DB Open in Design Mode or Download Connectivity patch @ https://www.microsoft.com/en-us/download/confirmation.aspx?id=23734"); ErrorWindow frm1 = new ErrorWindow("DB Open in Design Mode or Download Connectivity patch @ ", "https://www.microsoft.com/en-us/download/confirmation.aspx?id=23734"); return; } da.Dispose(); cn.Dispose(); noOfRec = dssx.Tables[0].Rows.Count; lbl_NoRec.Text = noOfRec.ToString() + " records."; //MessageBox.Show("pop" + noOfRec.ToString() + SearchCmd); //da = new OleDbDataAdapter("SELECT Identifier,ContactPosition FROM PositionType;", cn); //da.Fill(ds, "PositionType"); //da = new OleDbDataAdapter("SELECT Identifier, Badge FROM Badge", cn); //da.Fill(ds, "Badge"); } //MessageBox.Show("test"); DataGridViewTextBoxColumn ID = new DataGridViewTextBoxColumn { DataPropertyName = "ID", HeaderText = "ID " }; DataGridViewTextBoxColumn Song_Title = new DataGridViewTextBoxColumn { DataPropertyName = "Song_Title", HeaderText = "Song_Title " }; DataGridViewTextBoxColumn Song_Title_Sort = new DataGridViewTextBoxColumn { DataPropertyName = "Song_Title_Sort", HeaderText = "Song_Title_Sort " }; DataGridViewTextBoxColumn Album = new DataGridViewTextBoxColumn { DataPropertyName = "Album", HeaderText = "Album " }; DataGridViewTextBoxColumn Artist = new DataGridViewTextBoxColumn { DataPropertyName = "Artist", HeaderText = "Artist " }; DataGridViewTextBoxColumn Artist_Sort = new DataGridViewTextBoxColumn { DataPropertyName = "Artist_Sort", HeaderText = "Artist_Sort " }; DataGridViewTextBoxColumn Album_Year = new DataGridViewTextBoxColumn { DataPropertyName = "Album_Year", HeaderText = "Album_Year " }; DataGridViewTextBoxColumn AverageTempo = new DataGridViewTextBoxColumn { DataPropertyName = "AverageTempo", HeaderText = "AverageTempo " }; DataGridViewTextBoxColumn Volume = new DataGridViewTextBoxColumn { DataPropertyName = "Volume", HeaderText = "Volume " }; DataGridViewTextBoxColumn Preview_Volume = new DataGridViewTextBoxColumn { DataPropertyName = "Preview_Volume", HeaderText = "Preview_Volume " }; DataGridViewTextBoxColumn AlbumArtPath = new DataGridViewTextBoxColumn { DataPropertyName = "AlbumArtPath", HeaderText = "AlbumArtPath " }; DataGridViewTextBoxColumn AudioPath = new DataGridViewTextBoxColumn { DataPropertyName = "AudioPath", HeaderText = "AudioPath " }; DataGridViewTextBoxColumn audioPreviewPath = new DataGridViewTextBoxColumn { DataPropertyName = "audioPreviewPath", HeaderText = "audioPreviewPath " }; DataGridViewTextBoxColumn Track_No = new DataGridViewTextBoxColumn { DataPropertyName = "Track_No", HeaderText = "Track_No " }; DataGridViewTextBoxColumn Author = new DataGridViewTextBoxColumn { DataPropertyName = "Author", HeaderText = "Author " }; DataGridViewTextBoxColumn Version = new DataGridViewTextBoxColumn { DataPropertyName = "Version", HeaderText = "Version " }; DataGridViewTextBoxColumn DLC_Name = new DataGridViewTextBoxColumn { DataPropertyName = "DLC_Name", HeaderText = "DLC_Name " }; DataGridViewTextBoxColumn DLC_AppID = new DataGridViewTextBoxColumn { DataPropertyName = "DLC_AppID", HeaderText = "DLC_AppID " }; DataGridViewTextBoxColumn Current_FileName = new DataGridViewTextBoxColumn { DataPropertyName = "Current_FileName", HeaderText = "Current_FileName " }; DataGridViewTextBoxColumn Original_FileName = new DataGridViewTextBoxColumn { DataPropertyName = "Original_FileName", HeaderText = "Original_FileName " }; DataGridViewTextBoxColumn Import_Path = new DataGridViewTextBoxColumn { DataPropertyName = "Import_Path", HeaderText = "Import_Path " }; DataGridViewTextBoxColumn Import_Date = new DataGridViewTextBoxColumn { DataPropertyName = "Import_Date", HeaderText = "Import_Date " }; DataGridViewTextBoxColumn Folder_Name = new DataGridViewTextBoxColumn { DataPropertyName = "Folder_Name", HeaderText = "Folder_Name " }; DataGridViewTextBoxColumn File_Size = new DataGridViewTextBoxColumn { DataPropertyName = "File_Size", HeaderText = "File_Size " }; DataGridViewTextBoxColumn File_Hash = new DataGridViewTextBoxColumn { DataPropertyName = "File_Hash", HeaderText = "File_Hash " }; DataGridViewTextBoxColumn Original_File_Hash = new DataGridViewTextBoxColumn { DataPropertyName = "Original_File_Hash", HeaderText = "Original_File_Hash " }; DataGridViewTextBoxColumn Is_Original = new DataGridViewTextBoxColumn { DataPropertyName = "Is_Original", HeaderText = "Is_Original " }; DataGridViewTextBoxColumn Is_OLD = new DataGridViewTextBoxColumn { DataPropertyName = "Is_OLD", HeaderText = "Is_OLD " }; DataGridViewTextBoxColumn Is_Beta = new DataGridViewTextBoxColumn { DataPropertyName = "Is_Beta", HeaderText = "Is_Beta " }; DataGridViewTextBoxColumn Is_Alternate = new DataGridViewTextBoxColumn { DataPropertyName = "Is_Alternate", HeaderText = "Is_Alternate " }; DataGridViewTextBoxColumn Is_Multitrack = new DataGridViewTextBoxColumn { DataPropertyName = "Is_Multitrack", HeaderText = "Is_Multitrack " }; DataGridViewTextBoxColumn Is_Broken = new DataGridViewTextBoxColumn { DataPropertyName = "Is_Broken", HeaderText = "Is_Broken " }; DataGridViewTextBoxColumn MultiTrack_Version = new DataGridViewTextBoxColumn { DataPropertyName = "MultiTrack_Version", HeaderText = "MultiTrack_Version " }; DataGridViewTextBoxColumn Alternate_Version_No = new DataGridViewTextBoxColumn { DataPropertyName = "Alternate_Version_No", HeaderText = "Alternate_Version_No " }; DataGridViewTextBoxColumn DLC = new DataGridViewTextBoxColumn { DataPropertyName = "DLC", HeaderText = "DLC " }; DataGridViewTextBoxColumn Has_Bass = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Bass", HeaderText = "Has_Bass " }; DataGridViewTextBoxColumn Has_Guitar = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Guitar", HeaderText = "Has_Guitar " }; DataGridViewTextBoxColumn Has_Lead = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Lead", HeaderText = "Has_Lead " }; DataGridViewTextBoxColumn Has_Rhythm = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Rhythm", HeaderText = "Has_Rhythm " }; DataGridViewTextBoxColumn Has_Combo = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Combo", HeaderText = "Has_Combo " }; DataGridViewTextBoxColumn Has_Vocals = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Vocals", HeaderText = "Has_Vocals " }; DataGridViewTextBoxColumn Has_Sections = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Sections", HeaderText = "Has_Sections " }; DataGridViewTextBoxColumn Has_Cover = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Cover", HeaderText = "Has_Cover " }; DataGridViewTextBoxColumn Has_Preview = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Preview", HeaderText = "Has_Preview " }; DataGridViewTextBoxColumn Has_Custom_Tone = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Custom_Tone", HeaderText = "Has_Custom_Tone " }; DataGridViewTextBoxColumn Has_DD = new DataGridViewTextBoxColumn { DataPropertyName = "Has_DD", HeaderText = "Has_DD " }; DataGridViewTextBoxColumn Has_Version = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Version", HeaderText = "Has_Version " }; DataGridViewTextBoxColumn Tunning = new DataGridViewTextBoxColumn { DataPropertyName = "Tunning", HeaderText = "Tunning " }; DataGridViewTextBoxColumn Bass_Picking = new DataGridViewTextBoxColumn { DataPropertyName = "Bass_Picking", HeaderText = "Bass_Picking " }; DataGridViewTextBoxColumn Tones = new DataGridViewTextBoxColumn { DataPropertyName = "Tones", HeaderText = "Tones " }; DataGridViewTextBoxColumn Groups = new DataGridViewTextBoxColumn { DataPropertyName = "Groups", HeaderText = "Groups " }; DataGridViewTextBoxColumn Rating = new DataGridViewTextBoxColumn { DataPropertyName = "Rating", HeaderText = "Rating " }; DataGridViewTextBoxColumn Description = new DataGridViewTextBoxColumn { DataPropertyName = "Description", HeaderText = "Description " }; DataGridViewTextBoxColumn Comments = new DataGridViewTextBoxColumn { DataPropertyName = "Comments", HeaderText = "Comments " }; DataGridViewTextBoxColumn Has_Track_No = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Track_No", HeaderText = "Has_Track_No " }; DataGridViewTextBoxColumn Platform = new DataGridViewTextBoxColumn { DataPropertyName = "Platform", HeaderText = "Platform " }; DataGridViewTextBoxColumn PreviewTime = new DataGridViewTextBoxColumn { DataPropertyName = "PreviewTime", HeaderText = "PreviewTime " }; DataGridViewTextBoxColumn PreviewLenght = new DataGridViewTextBoxColumn { DataPropertyName = "PreviewLenght", HeaderText = "PreviewLenght " }; DataGridViewTextBoxColumn Temp = new DataGridViewTextBoxColumn { DataPropertyName = "Temp", HeaderText = "Temp " }; DataGridViewTextBoxColumn CustomForge_Followers = new DataGridViewTextBoxColumn { DataPropertyName = "CustomForge_Followers", HeaderText = "CustomForge_Followers " }; DataGridViewTextBoxColumn CustomForge_Version = new DataGridViewTextBoxColumn { DataPropertyName = "CustomForge_Version", HeaderText = "CustomForge_Version " }; DataGridViewTextBoxColumn Show_Available_Instruments = new DataGridViewTextBoxColumn { DataPropertyName = "Show_Available_Instruments", HeaderText = "Show_Available_Instruments " }; DataGridViewTextBoxColumn Show_Alternate_Version = new DataGridViewTextBoxColumn { DataPropertyName = "Show_Alternate_Version", HeaderText = "Show_Alternate_Version " }; DataGridViewTextBoxColumn Show_MultiTrack_Details = new DataGridViewTextBoxColumn { DataPropertyName = "Show_MultiTrack_Details", HeaderText = "Show_MultiTrack_Details " }; DataGridViewTextBoxColumn Show_Group = new DataGridViewTextBoxColumn { DataPropertyName = "Show_Group", HeaderText = "Show_Group " }; DataGridViewTextBoxColumn Show_Beta = new DataGridViewTextBoxColumn { DataPropertyName = "Show_Beta", HeaderText = "Show_Beta " }; DataGridViewTextBoxColumn Show_Broken = new DataGridViewTextBoxColumn { DataPropertyName = "Show_Broken", HeaderText = "Show_Broken " }; DataGridViewTextBoxColumn Show_DD = new DataGridViewTextBoxColumn { DataPropertyName = "Show_DD", HeaderText = "Show_DD " }; DataGridViewTextBoxColumn Original = new DataGridViewTextBoxColumn { DataPropertyName = "Original", HeaderText = "Original " }; DataGridViewTextBoxColumn Selected = new DataGridViewTextBoxColumn { DataPropertyName = "Selected", HeaderText = "Selected " }; DataGridViewTextBoxColumn YouTube_Link = new DataGridViewTextBoxColumn { DataPropertyName = "YouTube_Link", HeaderText = "YouTube_Link " }; DataGridViewTextBoxColumn CustomsForge_Link = new DataGridViewTextBoxColumn { DataPropertyName = "CustomsForge_Link", HeaderText = "CustomsForge_Link " }; DataGridViewTextBoxColumn CustomsForge_Like = new DataGridViewTextBoxColumn { DataPropertyName = "CustomsForge_Like", HeaderText = "CustomsForge_Like " }; DataGridViewTextBoxColumn CustomsForge_ReleaseNotes = new DataGridViewTextBoxColumn { DataPropertyName = "CustomsForge_ReleaseNotes", HeaderText = "CustomsForge_ReleaseNotes " }; DataGridViewTextBoxColumn SignatureType = new DataGridViewTextBoxColumn { DataPropertyName = "SignatureType", HeaderText = "SignatureType " }; DataGridViewTextBoxColumn ToolkitVersion = new DataGridViewTextBoxColumn { DataPropertyName = "ToolkitVersion", HeaderText = "ToolkitVersion " }; DataGridViewTextBoxColumn Has_Author = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Author", HeaderText = "Has_Author " }; DataGridViewTextBoxColumn OggPath = new DataGridViewTextBoxColumn { DataPropertyName = "OggPath", HeaderText = "OggPath " }; DataGridViewTextBoxColumn oggPreviewPath = new DataGridViewTextBoxColumn { DataPropertyName = "oggPreviewPath", HeaderText = "oggPreviewPath " }; DataGridViewTextBoxColumn UniqueDLCName = new DataGridViewTextBoxColumn { DataPropertyName = "UniqueDLCName", HeaderText = "UniqueDLCName " }; DataGridViewTextBoxColumn AlbumArt_Hash = new DataGridViewTextBoxColumn { DataPropertyName = "AlbumArt_Hash", HeaderText = "AlbumArt_Hash " }; DataGridViewTextBoxColumn Audio_Hash = new DataGridViewTextBoxColumn { DataPropertyName = "Audio_Hash", HeaderText = "Audio_Hash " }; DataGridViewTextBoxColumn audioPreview_Hash = new DataGridViewTextBoxColumn { DataPropertyName = "audioPreview_Hash", HeaderText = "audioPreview_Hash " }; DataGridViewTextBoxColumn Bass_Has_DD = new DataGridViewTextBoxColumn { DataPropertyName = "Bass_Has_DD", HeaderText = "Bass_Has_DD " }; DataGridViewTextBoxColumn Has_Bonus_Arrangement = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Bonus_Arrangement", HeaderText = "Has_Bonus_Arrangement " }; DataGridViewTextBoxColumn Artist_ShortName = new DataGridViewTextBoxColumn { DataPropertyName = "Artist_ShortName", HeaderText = "Artist_ShortName " }; DataGridViewTextBoxColumn Album_ShortName = new DataGridViewTextBoxColumn { DataPropertyName = "Album_ShortName", HeaderText = "Album_ShortName " }; DataGridViewTextBoxColumn Available_Old = new DataGridViewTextBoxColumn { DataPropertyName = "Available_Old", HeaderText = "Available_Old " }; DataGridViewTextBoxColumn Available_Duplicate = new DataGridViewTextBoxColumn { DataPropertyName = "Available_Duplicate", HeaderText = "Available_Duplicate " }; DataGridViewTextBoxColumn Has_Been_Corrected = new DataGridViewTextBoxColumn { DataPropertyName = "Has_Been_Corrected", HeaderText = "Has_Been_Corrected " }; //bsPositions.DataSource = ds.Tables["Main"]; //bsBadges.DataSource = ds.Tables["Badge"]; //DataGridViewComboBoxColumn ContactPositionColumn = new DataGridViewComboBoxColumn // { // DataPropertyName = "ContactPosition", // DataSource = bsPositions, // DisplayMember = "ContactPosition", // DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing, // Name = "ContactsColumn", // HeaderText = "Position", // SortMode = DataGridViewColumnSortMode.Automatic, // ValueMember = "ContactPosition" // }; //DataGridViewComboBoxColumn BadgeColumn = new DataGridViewComboBoxColumn // { // DataPropertyName = "Badge", // DataSource = bsBadges, // DisplayMember = "Badge", // DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing, // Name = "BadgeColumn", // HeaderText = "Badge", // SortMode = DataGridViewColumnSortMode.Automatic, // ValueMember = "Badge" // }; DataGridView.AutoGenerateColumns = false; DataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, Song_Title, Song_Title_Sort, Album, Artist, Artist_Sort, Album_Year, AverageTempo, Volume, Preview_Volume, AlbumArtPath, AudioPath, audioPreviewPath, Track_No, Author, Version, DLC_Name, DLC_AppID, Current_FileName, Original_FileName, Import_Path, Import_Date, Folder_Name, File_Size, File_Hash, Original_File_Hash, Is_Original, Is_OLD, Is_Beta, Is_Alternate, Is_Multitrack, Is_Broken, MultiTrack_Version, Alternate_Version_No, DLC, Has_Bass, Has_Guitar, Has_Lead, Has_Rhythm, Has_Combo, Has_Vocals, Has_Sections, Has_Cover, Has_Preview, Has_Custom_Tone, Has_DD, Has_Version, Tunning, Bass_Picking, Tones, Groups, Rating, Description, Comments, Has_Track_No, Platform, PreviewTime, PreviewLenght, Temp, CustomForge_Followers, CustomForge_Version, Show_Available_Instruments, Show_Alternate_Version, Show_MultiTrack_Details, Show_Group, Show_Beta, Show_Broken, Show_DD, Original, Selected, YouTube_Link, CustomsForge_Link, CustomsForge_Like, CustomsForge_ReleaseNotes, SignatureType, ToolkitVersion, Has_Author, OggPath, oggPreviewPath, UniqueDLCName, AlbumArt_Hash, Audio_Hash, audioPreview_Hash, Bass_Has_DD, Has_Bonus_Arrangement, Artist_ShortName, Album_ShortName, Available_Old, Available_Duplicate, Has_Been_Corrected } ); bs.ResetBindings(false); dssx.Tables["Main"].AcceptChanges(); bs.DataSource = dssx.Tables["Main"]; DataGridView.AutoGenerateColumns = false; DataGridView.DataSource = null; DataGridView.DataSource = bs; DataGridView.AutoGenerateColumns = false; DataGridView.Refresh(); //bs.Dispose(); dssx.Dispose(); //MessageBox.Show("-"); //DataGridView.ExpandColumns(); }
public void ConfiguraDataGrid(DataGridView dg, BindingSource bs) { //popula o datagrid retornado dg.RowsDefaultCellStyle.BackColor = Color.White; dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue; dg.EnableHeadersVisualStyles = true; dg.DataSource = bs; //formata as colunas do datagrid dg.Columns["Id"].HeaderText = "Reg. nº"; //Nome coluna dg.Columns["Id"].Width = 78; //largura coluna dg.Columns["Id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Id"].ToolTipText = "Número do Registro"; dg.Columns["Id"].DefaultCellStyle.Format = "0000000"; dg.Columns["Id"].Visible = true; dg.Columns["Item"].HeaderText = "Descrição"; //Nome coluna dg.Columns["Item"].Width = 400; //largura coluna dg.Columns["Item"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Item"].ToolTipText = "Descrição Item"; dg.Columns["Item"].Visible = true; dg.Columns["Produto"].HeaderText = "Produto"; //Nome coluna dg.Columns["Produto"].Width = 845; //largura coluna dg.Columns["Produto"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Produto"].ToolTipText = "Produto"; dg.Columns["Produto"].Visible = false; dg.Columns["Qtd"].HeaderText = "QTD"; //Nome coluna dg.Columns["Qtd"].Width = 80; //largura coluna dg.Columns["Qtd"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Qtd"].ToolTipText = "Quantidade"; dg.Columns["Qtd"].Visible = true; dg.Columns["Observacao"].HeaderText = "Observações"; //Nome coluna dg.Columns["Observacao"].Width = 465; //largura coluna dg.Columns["Observacao"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Observacao"].ToolTipText = "Observações"; dg.Columns["Observacao"].Visible = true; dg.Refresh(); }
private void ImportLegendXmlForStudy(IIntervalStudy study, XmlDocument doc, DataGridView dataGridView) { XmlNode node = doc.ChildNodes[1]; XmlNode node2 = node.ChildNodes[0].ChildNodes[0]; string valueStr = string.Empty; string str3 = string.Empty; float num = 0f; float num2 = 0f; int argb = 0; dataGridView.Rows.Clear(); int num4 = 0; foreach (XmlNode node3 in node2.ChildNodes) { argb = int.Parse(node3.Attributes["color"].Value); valueStr = node3.Attributes["minvalue"].Value; str3 = node3.Attributes["maxvalue"].Value; num = LegendAndValueAnalyse.AnalyseMaxMinValue(valueStr); num2 = LegendAndValueAnalyse.AnalyseMaxMinValue(str3); num4 = dataGridView.Rows.Add(); dataGridView.Rows[num4].Cells["ColorType"].Value = Color.FromArgb(argb); dataGridView.Rows[num4].Cells["MinValue"].Value = LegendAndValueAnalyse.AnalyseMaxMinValue(num); dataGridView.Rows[num4].Cells["MaxValue"].Value = LegendAndValueAnalyse.AnalyseMaxMinValue(num2); dataGridView.Rows[num4].Cells["Legend"].Value = LegendAndValueAnalyse.CombineLegendStr(study.Unit, study.Name, num2, num); dataGridView.Rows[num4].Cells["CheckLegend"].Value = true; } dataGridView.Refresh(); }
private void ImportLegendXmlForStudy(IDiscreteStudy study, XmlDocument doc, DataGridView dataGridView) { XmlNode node = doc.ChildNodes[1]; XmlNode node2 = node.ChildNodes[0].ChildNodes[0]; string str2 = string.Empty; string str3 = string.Empty; int argb = 0; dataGridView.Rows.Clear(); int num2 = 0; foreach (XmlNode node3 in node2.ChildNodes) { argb = int.Parse(node3.Attributes["color"].Value); str2 = node3.Attributes["value"].Value; str3 = node3.Attributes["legend"].Value; num2 = dataGridView.Rows.Add(); dataGridView.Rows[num2].Cells["ColorType"].Value = Color.FromArgb(argb); dataGridView.Rows[num2].Cells["value"].Value = str2; dataGridView.Rows[num2].Cells["Legend"].Value = str3; dataGridView.Rows[num2].Cells["CheckLegend"].Value = true; } dataGridView.Refresh(); }
private DataGridView CopyDataGridView(DataGridView dgv_org) { DataGridView dgv_copy = new DataGridView(); try { if (dgv_copy.Columns.Count == 0) { foreach (DataGridViewColumn dgvc in dgv_org.Columns) { dgv_copy.Columns.Add(dgvc.Clone() as DataGridViewColumn); } } DataGridViewRow row = new DataGridViewRow(); for (int i = 0; i < dgv_org.Rows.Count; i++) { row = (DataGridViewRow)dgv_org.Rows[i].Clone(); int intColIndex = 0; foreach (DataGridViewCell cell in dgv_org.Rows[i].Cells) { row.Cells[intColIndex].Value = cell.Value; intColIndex++; } dgv_copy.Rows.Add(row); } dgv_copy.AllowUserToAddRows = false; dgv_copy.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); //cf.ShowExceptionErrorMsg("Copy DataGridViw", ex); } return dgv_copy; }
public void Pesquisar(DataGridView dg) { RelatorioControl rControl = new RelatorioControl(); BindingSource pesquisa = new BindingSource(); pesquisa.DataSource = rControl.GetRelatorios(); dg.DataSource = pesquisa; if (pesquisa.Count <= 0) //trata o caso q a busca é vazia. { return; } //popula o datagrid retornado dg.RowsDefaultCellStyle.BackColor = Color.White; dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue; dg.EnableHeadersVisualStyles = true; //formata as colunas do datagrid dg.Columns["Id"].HeaderText = "Rel. nº"; //Nome coluna dg.Columns["Id"].Width = 78; //largura coluna dg.Columns["Id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Id"].ToolTipText = "Número do Relatório"; dg.Columns["Id"].DefaultCellStyle.Format = "0000000"; dg.Columns["Id"].Visible = true; dg.Columns["Descricao"].HeaderText = "Descrição"; //Nome coluna dg.Columns["Descricao"].Width = 597; //largura coluna dg.Columns["Descricao"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dg.Columns["Descricao"].ToolTipText = "Descrição do Relatório"; dg.Columns["Descricao"].Visible = true; dg.Refresh(); }