http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp

解决方案 »

  1.   

    int _UnSortColumn = -1;
    /// <summary>
    /// 不允许排序的列号
    /// </summary>
    public int UnSortColumn
    {
    get
    {
    return _UnSortColumn;
    }
    set
    {
    _UnSortColumn = value;
    }
    } protected override void OnMouseDown(MouseEventArgs e)
    {
    HitTestInfo info = this.HitTest(e.X,e.Y);
    if(info.Column == this.UnSortColumn && info.Type == HitTestType.ColumnHeader)
    {
    return;
    }
    base.OnMouseDown (e);
                       }
      

  2.   

    1.可以不用DataTable或DataSet绑定DataGrid,而用DataView绑定DataGrid,DataView有Sort
    属性,用它排序。
    2.
    5.58  How can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key? 
    http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q889q
      

  3.   

    用DataView怎么绑定?没有用过,请指教。我前面的程序都是用DataTable,如果要改成DataView,需要修改的地方多吗?
      

  4.   

    为什么我在DataGrid里面设置了AllowSorting=false也没什么效果。
      

  5.   

    re:cmic 你给的那个网页打不开,继续提问。
      

  6.   

    在DATAGrid中,当全选中一行时,按Delete键,DataGrid会自动删除选择的行,请问,在DataGrid中,删除前会发送消息出来吗?什么消息?
      

  7.   

    根据 CMIC(大象) 提供链接转载
    1.How do I prevent sorting a single column in my DataGrid?     You can do this by deriving the DataGrid and overriding OnMouseDowm. In your override, do a HitText and if the hit is on a column header that you do not want to sort, do not call the baseclass. Here is a code that sorts all columns except the second column 
     
    [C#] 
     
    //derived class 
     
    public class MyDataGrid : DataGrid 
     

     
         protected override void OnMouseDown(MouseEventArgs e) 
     
         { 
     
              Point pt = new Point(e.X, e.Y); 
     
              DataGrid.HitTestInfo hti = this.HitTest(pt); 
     
              if(hti.Type == HitTestType.ColumnHeader && hti.Column == 1) 
     
              { 
     
                   //don't sort col 1 
     
                   return; //don't call baseclass 
     
              } 
     
              base.OnMouseDown(e); 
     
         } 
     

     
    2.How can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key?     You can handle this by subclassing your grid and overriding either PreProcessMessage or ProcessDialogKey. The code below assumes your datasource is a dataview. If it is not, you could just remove that check 
     
    [C#] 
     
    public override bool PreProcessMessage( ref Message msg ) 
     

     
         Keys keyCode = (Keys)(int)msg.WParam & Keys.KeyCode; 
     
         if(msg.Msg == WM_KEYDOWN 
     
              && keyCode == Keys.Delete 
     
              && ((DataView) this.DataSource).AllowDelete) 
     
         { 
     
              if(MessageBox.Show("Delete this row?", "", MessageBoxButtons.YesNo) == DialogResult.No) 
     
                   return true; 
     
         } 
     
         return base.PreProcessMessage(ref msg); 
     

     
      

  8.   

    1.从DataTable的DefaultView可以获得它对应的DataView。
    2.网页可以打开你在试试。
      

  9.   

    问题解决, Samen168(Samen),CMIC(大象),gkwww(奔放) 是正解,另外感谢cyatzzu(懒人) 的拔刀相助。