public GinLoadsPage() { InitializeComponent(); dataGridLoads.AutoGenerateColumns = false; // Creating checkbox without panel checkbox.Size = new System.Drawing.Size(15, 15); checkbox.BackColor = Color.Transparent; // Reset properties checkbox.Padding = new Padding(0); checkbox.Margin = new Padding(0); checkbox.Text = ""; // Add checkbox to datagrid cell dataGridLoads.Controls.Add(checkbox); checkbox.CheckedChanged += Checkbox_CheckedChanged; DataGridViewHeaderCell header = dataGridLoads.Columns[0].HeaderCell; checkbox.Location = new Point( header.ContentBounds.Left + (header.ContentBounds.Right - header.ContentBounds.Left + checkbox.Width) / 2 + 53, header.ContentBounds.Top + (header.ContentBounds.Bottom - header.ContentBounds.Top + checkbox.Size.Height) / 2 ); }
public void AddHeaderCheckBox() { // Header checkbox this.HeaderCheckBox = new CheckBox { Size = new Size(15, 15), BackColor = Color.Transparent, Padding = new Padding(0), Margin = new Padding(0), Text = string.Empty }; this.AllSteamItemsGridView.Controls.Add(this.HeaderCheckBox); DataGridViewHeaderCell header = this.AllSteamItemsGridView.Columns[0].HeaderCell; this.HeaderCheckBox.Location = new Point( (header.ContentBounds.Left + (header.ContentBounds.Right - header.ContentBounds.Left + this.HeaderCheckBox.Size.Width) / 2) + 3, (header.ContentBounds.Top + (header.ContentBounds.Bottom - header.ContentBounds.Top + this.HeaderCheckBox.Size.Height) / 2) + 3); this.HeaderCheckBox.CheckStateChanged += HeaderCheckBoxOnCheckStateChanged; }
private void AddSelectorColumn(DataGridView grid) { var selectorColumn = new DataGridViewCheckBoxColumn { Name = SelectedColumnName, Width = 60, HeaderText = string.Empty, Selected = false, FalseValue = false, TrueValue = true }; grid.Columns.Add(selectorColumn); var checkbox = new CheckBox { Size = new Size(45, 15), BackColor = Color.Transparent, Padding = new Padding(0), Margin = new Padding(0), Name = "SelectAll", TextAlign = ContentAlignment.MiddleCenter, Text = "All" }; checkbox.Click += SelectAllCheckbox_Click; grid.Controls.Add(checkbox); DataGridViewHeaderCell header = grid.Columns[selectorColumn.Index].HeaderCell; checkbox.Location = new Point( header.ContentBounds.Left + (header.ContentBounds.Right - header.ContentBounds.Left + checkbox.Size.Width) / 2, header.ContentBounds.Top + (header.ContentBounds.Bottom - header.ContentBounds.Top + checkbox.Size.Height) / 2 ); }
public Form1() { InitializeComponent(); DataGridView dgv = new DataGridView(); // add some columns and rows for (int i = 0; i < 10; i++) { DataGridViewCell c = new DataGridViewHeaderCell(); dgv.Columns.Add("Column" + i, Convert.ToString(i)); } for (int i = 0; i < 10; i++) { dgv.Rows.Add(new DataGridViewRow()); } //create a new DataGridViewComboBoxCell and give it a datasource var DGVComboBox = new DataGridViewComboBoxCell(); DGVComboBox.DataSource = new List <string> { "one", "two", "three" }; DGVComboBox.Value = "one"; // set default value of the combobox // add it to cell[4,4] of the DataGridView dgv[4, 4] = DGVComboBox; // add the DataGridView to the form this.Controls.Add(dgv); }
/// <summary> /// Converts the requested column into a checkbox column. /// </summary> /// <param name="dataGridView">The DataGridView to operate on.</param> /// <param name="column">The zero-based column index to convert to a checkbox column.</param> /// <param name="size">The size of the checkbox column to create. Defaults to 15 pixels.</param> /// <returns>The checkbox control created for the column.</returns> public static CheckBox ColumnCheckbox(this SwfDataGridView dataGridView, int column, Size?size = null) { var checkBox = new CheckBox { Size = size ?? new Size(15, 15), BackColor = System.Drawing.Color.Transparent, // Reset properties Padding = new Padding(0), Margin = new Padding(0), Text = "" }; // Add checkbox to datagrid cell dataGridView.Controls.Add(checkBox); DataGridViewHeaderCell header = dataGridView.Columns[column].HeaderCell; checkBox.Location = new Point( header.ContentBounds.Left + ((header.ContentBounds.Right - header.ContentBounds.Left + checkBox.Size.Width) / 2) + 3, header.ContentBounds.Top + ((header.ContentBounds.Bottom - header.ContentBounds.Top + checkBox.Size.Height) / 2) - 2); return(checkBox); }
/// <summary> /// Draw Grid column headers from partition /// </summary> /// <param name="g"></param> /// <param name="partition">Partition to print</param> /// <returns></returns> private float DrawColumnHeaders(Graphics g, Partition partition) { PartitionBounds bounds = partition.Bounds; float currentY = bounds.StartY; float currentX = bounds.StartX; // Setting the LinePen that will be used to draw lines and rectangles (derived from the GridColor property of the DataGridView control) Pen linePen = new Pen(GridView.GridColor, 1); // Calculating and drawing the HeaderBounds RectangleF HeaderBounds = new RectangleF(currentX, currentY, bounds.Width, columnHeaderHeight); g.FillRectangle( new SolidBrush(GridView.ColumnsHeaderBackColor()), HeaderBounds); // Setting the format that will be used to print each cell of the header row StringFormat CellFormat = new StringFormat(); CellFormat.Trimming = StringTrimming.Word; CellFormat.FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; // Printing each visible cell of the header row foreach (var column in partition.GetColumns().OrderBy(x => x.DisplayIndex)) { DataGridViewHeaderCell cell = column.HeaderCell; CellFormat.Alignment = cell.HorizontalAlignement(); RectangleF CellBounds = new RectangleF(currentX, currentY, columnWidths[column.Index], columnHeaderHeight); // Printing the cell text g.DrawString(column.HeaderText, cell.Font(scale), new SolidBrush(cell.ForeColor()), CellBounds, CellFormat); // Drawing the cell bounds if (GridView.RowHeadersBorderStyle != DataGridViewHeaderBorderStyle.None) // Draw the cell border only if the HeaderBorderStyle is not None { g.DrawRectangle(linePen, currentX, currentY, columnWidths[column.Index], columnHeaderHeight); } currentX += columnWidths[column.Index]; } return(currentY + columnHeaderHeight); }
private void Autofarmer_Load(object sender, EventArgs e) { // Set as Growtopia's default path this.KeyPreview = true; GrowtopiaPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Appdata\Local\Growtopia\Growtopia.exe"; // Dropdown list default values autoFarmerType.SelectedIndex = 0; multiboxToggle.SelectedIndex = 0; // Create checkbox for "Select all" in processList checkbox = new CheckBox(); checkbox.Size = new System.Drawing.Size(15, 15); checkbox.BackColor = Color.Transparent; checkbox.Padding = new Padding(0); checkbox.Margin = new Padding(0); checkbox.Text = ""; processList.Controls.Add(checkbox); DataGridViewHeaderCell header = processList.Columns["Checkbox"].HeaderCell; checkbox.Location = new Point(12, 10); checkbox.CheckedChanged += new EventHandler(SelectAll); // Timer to punch // Set the timer ms with the "Hits" setting punchTimer = new System.Timers.Timer(150); punchTimer.Elapsed += new System.Timers.ElapsedEventHandler(PunchClick); Process[] previousProcesses = Process.GetProcessesByName("Growtopia"); List <Process> sortedProcesses = previousProcesses.OrderBy(s => s.MainWindowTitle).ToList(); foreach (Process sortedProcess in sortedProcesses) { processes.Add(sortedProcess); processList.Rows.Add(); processList.Rows[processes.Count - 1].Cells["Number"].Value = processes.Count; processList.Rows[processes.Count - 1].Cells["Active"].Value = "None"; processList.Rows[processes.Count - 1].Cells["Multibox"].Value = "Disabled"; processList.Rows[processes.Count - 1].Cells["PID"].Value = sortedProcess.Id; if (processes.Count == 6) // Align checkbox { checkbox.Location = new Point(4, 10); } } openGTButton.Text = "Open GT (" + processes.Count + " open)"; statusMessage.Text = "Previous growtopias opened!"; }
private void UpdateHeaderCheckboxLocation(CheckBox checkBox, DataGridViewColumn column) { DataGridViewHeaderCell header = column.HeaderCell; int startX = DataGrid.Columns.Cast <DataGridViewColumn>().Where(x => x.Index < header.ColumnIndex).Sum(x => x.Width); int startY = 2; if (DataGrid.RowHeadersVisible) { startX += DataGrid.RowHeadersWidth; } checkBox.Location = new Point(startX + column.Width - checkBox.Width - 2, startY + (DataGrid.ColumnHeadersHeight - checkBox.Height) / 2); }
public AddEditPickupList() { InitializeComponent(); checkAllModules.CheckedChanged += Checkbox_CheckedChanged; checkAllTrucks.CheckedChanged += TruckCheckbox_CheckedChanged; checkAllModules.Size = new System.Drawing.Size(15, 15); checkAllModules.BackColor = Color.Transparent; checkAllModules.Padding = new Padding(0); checkAllModules.Margin = new Padding(0); checkAllModules.Text = ""; checkAllTrucks.Size = new System.Drawing.Size(15, 15); checkAllTrucks.BackColor = Color.Transparent; checkAllTrucks.Padding = new Padding(0); checkAllTrucks.Margin = new Padding(0); checkAllTrucks.Text = ""; availableModulesGridView.Controls.Add(checkAllModules); availableModulesGridView.Visible = false; lblCheckInfo.Text = "Loading modules..."; lblTruckInstructions.Text = "Loading trucks..."; pnlModuleStep.Enabled = false; pnlTruckStep.Enabled = false; DataGridViewHeaderCell headerModules = availableModulesGridView.Columns[0].HeaderCell; checkAllModules.Location = new Point( headerModules.ContentBounds.Left + (headerModules.ContentBounds.Right - headerModules.ContentBounds.Left + checkAllModules.Width) / 2 + 43, headerModules.ContentBounds.Top + (headerModules.ContentBounds.Bottom - headerModules.ContentBounds.Top + checkAllModules.Size.Height) / 2 - 13 ); gridViewTrucks.Controls.Add(checkAllTrucks); DataGridViewHeaderCell headerTrucks = gridViewTrucks.Columns[0].HeaderCell; checkAllTrucks.Location = new Point( headerTrucks.ContentBounds.Left + (headerTrucks.ContentBounds.Right - headerTrucks.ContentBounds.Left + checkAllTrucks.Width) / 2 + 53, headerTrucks.ContentBounds.Top + (headerTrucks.ContentBounds.Bottom - headerTrucks.ContentBounds.Top + checkAllTrucks.Size.Height) / 2 ); }
public void GridDesign() { this.dataGridView1.DefaultCellStyle.Font = new Font("Calibri", 11, FontStyle.Regular); dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("Calibri", 11.25f, FontStyle.Bold); DataGridViewCellStyle fooCellStyle = new DataGridViewCellStyle(); DataGridViewHeaderCell f = new DataGridViewHeaderCell(); dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Maroon; dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; dataGridView1.DefaultCellStyle.ForeColor = Color.White; dataGridView1.EnableHeadersVisualStyles = false; // dataGridView1.RowHeadersVisible = false; dataGridView1.ColumnHeadersVisible = false; //DataGridViewColumn dataGridViewColumn = dgvitem.Columns[2]; //dataGridViewColumn.HeaderCell.Style.BackColor = Color.Green; foreach (DataGridViewRow row in dataGridView1.Rows) { row.Cells[0].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[0].Style.BackColor = Color.LightGray; row.Cells[0].Style.ForeColor = Color.Black; row.Cells[1].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[1].Style.BackColor = Color.LightGray; row.Cells[1].Style.ForeColor = Color.Black; row.Cells[2].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[2].Style.BackColor = Color.LightGray; row.Cells[2].Style.ForeColor = Color.Black; row.Cells[3].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[3].Style.BackColor = Color.LightGray; row.Cells[3].Style.ForeColor = Color.Black; row.Cells[4].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[4].Style.BackColor = Color.LightGray; row.Cells[4].Style.ForeColor = Color.Black; row.Cells[5].Style.Font = new Font("Calibri", 11, FontStyle.Bold); row.Cells[5].Style.BackColor = Color.LightGray; row.Cells[5].Style.ForeColor = Color.Black; } // dgvitem.Enabled = false; }
private void AddCheckBoxHeader_() { CheckBox checkbox = new CheckBox(); checkbox.Size = new System.Drawing.Size(15, 15); checkbox.BackColor = Color.Transparent; // Reset properties checkbox.Padding = new Padding(0); checkbox.Margin = new Padding(0); checkbox.Text = ""; // Add checkbox to datagrid cell dgv_empreinte.Controls.Add(checkbox); DataGridViewHeaderCell header = dgv_empreinte.Columns["check_"].HeaderCell; checkbox.Location = new Point( header.ContentBounds.Left + (header.ContentBounds.Right - header.ContentBounds.Left + checkbox.Size.Width) / 2, header.ContentBounds.Top + (header.ContentBounds.Bottom - header.ContentBounds.Top + checkbox.Size.Height) / 2 ); }
public void createNewRouteHeaderCheckbox() { // Creating checkbox without panel newRouteHeaderCheckbox = new CheckBox(); newRouteHeaderCheckbox.Size = new System.Drawing.Size(15, 15); newRouteHeaderCheckbox.BackColor = Color.Transparent; // Reset properties newRouteHeaderCheckbox.Padding = new Padding(0); newRouteHeaderCheckbox.Margin = new Padding(0); newRouteHeaderCheckbox.Text = ""; // Add checkbox to datagrid cell this.newRouteTable.Controls.Add(newRouteHeaderCheckbox); DataGridViewHeaderCell header = newRouteTable.Columns[0].HeaderCell; newRouteHeaderCheckbox.Location = new Point( 70, 5 ); newRouteHeaderCheckbox.CheckStateChanged += new System.EventHandler(this.newRouteHeaderCheckbox_CheckStateChanged); }
public void setupForNewRoute() { // Display loading screen (create new thread for it) Thread myThread = new Thread(new ThreadStart(DisplayLoadingScreen)); myThread.Start(); // Populate Available Anchor List with data from Cosmos: // Clear Table if not empty newRouteTableLabel.Text = "New Route"; clearNewRouteTable(); HttpClient c = new HttpClient(); Task <string> t = c.GetStringAsync("https://sharingservice20200308094713.azurewebsites.net" + "/api/anchors/all"); try { var result = string.Join(",", t.Result); Console.WriteLine(result); string[] stringArray = result.Split(','); string[] anchorsFromAPI = new string[stringArray.Length]; // Remove the [ from the first element stringArray[0] = stringArray[0].Replace("[", ""); // Remove the ] from the last element stringArray[stringArray.Length - 1] = stringArray[stringArray.Length - 1].Replace("]", ""); int n = 0; newRouteTable.ReadOnly = false; if (uiState == RouteUIState.notActive) { foreach (string currStr in stringArray) { anchorsFromAPI[n] = currStr.Replace("\"", ""); // Add to the Dattatable this.availableNavPointsTable.Rows.Add(n + 1, anchorsFromAPI[n].Split(':')[0].Trim(), anchorsFromAPI[n].Split(':')[1].Trim(), anchorsFromAPI[n].Split(':')[2].Trim(), anchorsFromAPI[n].Split(':')[3].Trim(), anchorsFromAPI[n].Split(':')[4].Trim()); // For Avail Navpoint Table, Set all but checkboxes to read only availableNavPointsTable.ReadOnly = false; availableNavPointsTable.Rows[n].Cells["addBtns"].Value = false; availableNavPointsTable.Rows[n].Cells["addBtns"].ToolTipText = "Select for Addition to New Route"; availableNavPointsTable.Rows[n].Cells["availableNavPointsNavPointName"].ReadOnly = true; availableNavPointsTable.Rows[n].Cells["anchorDataFromAvailable"].ReadOnly = true; availableNavPointsTable.Rows[n].Cells["anchorExpirationFromAvailable"].ReadOnly = true; // Default the checkboxes to false // availableNavPointsTable.EditMode = DataGridViewEditMode.EditOnEnter; // Only should do this when adding the new row n++; } // Creating checkbox without panel myHeaderChkbox = new CheckBox(); myHeaderChkbox.Size = new System.Drawing.Size(15, 15); myHeaderChkbox.BackColor = Color.Transparent; // Reset properties myHeaderChkbox.Padding = new Padding(0); myHeaderChkbox.Margin = new Padding(0); myHeaderChkbox.Text = ""; // Add checkbox to datagrid cell this.availableNavPointsTable.Controls.Add(myHeaderChkbox); DataGridViewHeaderCell header = availableNavPointsTable.Rows[0].Cells["addBtns"].OwningColumn.HeaderCell; myHeaderChkbox.Location = new Point( 70, 5 ); myHeaderChkbox.CheckStateChanged += new System.EventHandler(this.myHeaderChkbox_CheckStateChanged); } } catch (AggregateException e) { abortLoadingForm(); MessageBox.Show("Unable to Connect to Database. Check Internet Connection", "No Connection", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } abortLoadingForm(); // When "Create New" is clicked under routes, // display the new route table and availableAnchorTable newRouteTable.Visible = true; newRouteTableLabel.Visible = true; availableNavPointsTableLabel.Visible = true; availableNavPointsTable.Visible = true; addAnchorToNewRouteBtn.Visible = true; removeAnchorFromNewRouteBtn.Visible = true; saveNewRouteBtn.Visible = true; updateAnchorBtn.Visible = true; loadBtn.Visible = true; }