发现datagrid中的数据超过一屏时 
datagrid里不能自动出现滚动条
这是为什么?

解决方案 »

  1.   

    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();                     
     
              } 
     
         } 
     

     
      

  2.   

    要自己重写类?
    要这么麻烦?这应该是一个很简单的问题!
    datagrid没有相关的属性么?
      

  3.   

    After scrolling with the mouse wheel on a selected row in a DataGrid I cannot get it back into view. Is there a work around?When you select a row in the DataGrid and scroll it out of view using the mouse wheel, you cannot get it back into view. The following is a workaround posted by one Windows Forms User: 
       
    this.dataGrid1.MouseWheel+=new MouseEventHandler(dataGrid1_MouseWheel); 
       
    private void dataGrid1_MouseWheel(object sender, MouseEventArgs e) 

         this.dataGrid1.Select(); 
       
      

  4.   

    .net里面数据多时,点一下GRID 框架就可以了
    如果点击数据单元格区好像不能滚动
      

  5.   

    我知道原因了
    主要 是我用了一下布局dock里面的fill datagrid就会填满整个窗口 这样的话那个scrollbar就显示不出来了但应该怎么解决呢》?