这个要看你需要了,下面是一个让垂直滚动条总是出现的DataGrid:public class MyDataGrid : DataGrid
{
public MyDataGrid()
{
//make scrollbar visible & hook up handler
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new EventHandler(ShowScrollBars);
}
private int CAPTIONHEIGHT = 21;
private int BORDERWIDTH = 2;
private void ShowScrollBars(object sender, EventArgs e)
{
if(!this.VertScrollBar.Visible)
{
int width = this.VertScrollBar.Width;
this.VertScrollBar.Location = new Point(this.ClientRectangle.Width - width - BORDERWIDTH, CAPTIONHEIGHT);
this.VertScrollBar.Size = new Size(width, this.ClientRectangle.Height - CAPTIONHEIGHT - BORDERWIDTH);
this.VertScrollBar.Show();
}
}
}
{
public MyDataGrid()
{
//make scrollbar visible & hook up handler
this.VertScrollBar.Visible = true;
this.VertScrollBar.VisibleChanged += new EventHandler(ShowScrollBars);
}
private int CAPTIONHEIGHT = 21;
private int BORDERWIDTH = 2;
private void ShowScrollBars(object sender, EventArgs e)
{
if(!this.VertScrollBar.Visible)
{
int width = this.VertScrollBar.Width;
this.VertScrollBar.Location = new Point(this.ClientRectangle.Width - width - BORDERWIDTH, CAPTIONHEIGHT);
this.VertScrollBar.Size = new Size(width, this.ClientRectangle.Height - CAPTIONHEIGHT - BORDERWIDTH);
this.VertScrollBar.Show();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货