GridControl only show scrollbars when needed


Thank you for your interest in Syncfusion products.
We suggest you to make use of the HScroll and Vscroll properties for disabling and enabling the Horizontal and Vertical ScrollBar to your needs. By seeing the code you have given I suggest you to use disable these properties when the width and height is less than that of the GridControl. Please refer the below code.
|
C#: private void ResizeGrid() { //get the columns to fill the entire grid. //horizontal scrollbar should only appear if gridControl1.Width < gridControl1.ColWidths[1] + gridControl1.ColWidths[2]) gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(1, 2)); if (gridControl1.Width >= gridControl1.ColWidths[1] + gridControl1.ColWidths[2]) { gridControl1.ColWidths[2] = gridControl1.Width - gridControl1.ColWidths[1]; this.gridControl1.HScroll = false; this.gridControl1.HScrollBehavior = GridScrollbarMode.Disabled; } else { this.gridControl1.HScroll = true; this.gridControl1.HScrollBehavior = GridScrollbarMode.Enabled; }
//get the rows to fill the entire grid by adjusting the height of the filler row //vertical scrollbar should only appear if gridControl1.Height < rowHeight int rowHeight = 0; for (int i = 1; i <= NumInputs; i++) rowHeight += gridControl1.RowHeights[i]; if (gridControl1.Height <= rowHeight) { gridControl1.RowHeights[NumInputs + 1] = 0; this.gridControl1.VScroll = true; this.gridControl1.VScrollBehavior = GridScrollbarMode.Enabled; } else { this.gridControl1.VScroll = false; this.gridControl1.VScrollBehavior = GridScrollbarMode.Disabled; gridControl1.RowHeights[NumInputs + 1] = gridControl1.Height - rowHeight; } |
And for disabling the highlight option of the cells we suggest you to use the Allow Selection property as none. Please check the following code for you reference.
|
C#: this.gridControl1.AllowSelection = GridSelectionFlags.None; |
Please let us know If you need any further assistance.
Regards,
Anish.
We are glad that the reported query has been resolved. Please let us know if you need any further assistance.
Regards,
Ansih.
- 3 Replies
- 2 Participants
-
TT tttmack
- Jun 2, 2015 03:44 AM UTC
- Jun 4, 2015 10:45 AM UTC