Skip to content

Instantly share code, notes, and snippets.

@rockhymas
Created June 23, 2012 13:39
Show Gist options
  • Save rockhymas/2978331 to your computer and use it in GitHub Desktop.
Save rockhymas/2978331 to your computer and use it in GitHub Desktop.
ResizeGridColumns
private const int LAST_COL_MARGIN = 12;
private void ResizeGridColumns()
{
var verticalScrollBar = dataGrid.GetDataGridVerticalScrollBar();
var verticalScrollBarWidth = verticalScrollBar != null ? verticalScrollBar.Width : 0;
var horizontalScrollbar = dataGrid.GetDataGridHorizontalScrollBar();
if (horizontalScrollbar != null)
horizontalScrollbar.Visible = false;
if (dataGrid.TableStyles.Count > 0)
{
var tableStyle = dataGrid.TableStyles[0];
tableStyle.GridColumnStyles[0].Width = dataGrid.ClientSize.Width - verticalScrollBarWidth - LAST_COL_MARGIN;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment