C
C#11mo ago
Lord Jinxy

Disabling sorting for a specific DataGridView column

I am trying to make sure that when sorting any other column, a certain column (let it be column A) is not automatically sorted along with them. Disabling sorting using DataGridViewColumnSortMode.NotSortable removes the ability to sort by column A directly, but if others are sorted, the column A is sorted with them.
No description
2 Replies
Lord Jinxy
Lord JinxyOP11mo ago
A fragment from the Designer.cs automade file regarding DataGridView element creation.
this.mainTable.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.mainTable.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.mainTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.mainTable.Location = new System.Drawing.Point(15, 163);
this.mainTable.MultiSelect = false;
this.mainTable.Name = "dataGridView1";
this.mainTable.ReadOnly = true;
this.mainTable.RowHeadersWidth = 51;
this.mainTable.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
this.mainTable.RowTemplate.Height = 24;
this.mainTable.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.mainTable.SelectionMode = DataGridViewSelectionMode.CellSelect;
this.mainTable.Size = new System.Drawing.Size(240, 150);
this.mainTable.TabIndex = 7;
this.mainTable.Visible = false;
this.mainTable.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.mainTable.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.mainTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.mainTable.Location = new System.Drawing.Point(15, 163);
this.mainTable.MultiSelect = false;
this.mainTable.Name = "dataGridView1";
this.mainTable.ReadOnly = true;
this.mainTable.RowHeadersWidth = 51;
this.mainTable.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
this.mainTable.RowTemplate.Height = 24;
this.mainTable.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.mainTable.SelectionMode = DataGridViewSelectionMode.CellSelect;
this.mainTable.Size = new System.Drawing.Size(240, 150);
this.mainTable.TabIndex = 7;
this.mainTable.Visible = false;
Want results from more Discord servers?
Add your server