简体   繁体   中英

Datagridview column SortGlyph indicator is hidden behind scrollbar

I have a winform application with a Datagridview that has 6 columns. All columns except col. 4 are sortable. Sorting is initiated by clicking on a column header and grid will sort on that column. All this works. My problem is that when I have more than 17 rows of data in the grid, a vertical scrollbar will appear (which is what I want). However, the vertical scrollbar hides SortGlyph triangle if I happen to be sorting on the last column in the grid. The user won't be able to see the sort direction. This is not an issue if I sort on other columns. I would like the columns to adjust properly (width-wise) when the vertical scrollbar appears so that I can see the SortGlyph indicator at all times. NOTE: I only show a vertical scroll (not horz scrollbar) for the grid. My form is not sizable and uses FormBorderStyle.Fixed3D. The grid is set to DockStyle.Fill.

Some relevent code:

this.GridView_DocumentStatus.AllowUserToAddRows = false;
this.GridView_DocumentStatus.AllowUserToDeleteRows = false;
this.GridView_DocumentStatus.AllowUserToResizeRows = false;
dataGridViewCellStyle1.Alignment =DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.WrapMode = DataGridViewTriState.True;
this.GridView_DocumentStatus.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;

this.GridView_DocumentStatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.GridView_DocumentStatus.EnableHeadersVisualStyles = false;
this.GridView_DocumentStatus.Location = new System.Drawing.Point(0, 0);
this.GridView_DocumentStatus.MultiSelect = false;
this.GridView_DocumentStatus.ReadOnly = true;
this.GridView_DocumentStatus.RowHeadersVisible = false;
this.GridView_DocumentStatus.ScrollBars = ScrollBars.Vertical;
this.GridView_DocumentStatus.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

I must have some setting wrong causing this effect. -OR- Is this something I have to micro-manage by manually adjusting the columns myself (that would suck).

Change the layout setting of your last column to fill, which will readjust the column width when the vertical scroll bar appears:

Column6.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Column6.FillWeight = 100;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM