private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
try
{
DataGrid.HitTestInfo
hitInfo=dataGrid1.HitTest(e.X,e.Y);
switch(hitInfo.Type)
{
case DataGrid.HitTestType.Cell:
this.dataGrid1.Select(hitInfo.Row);
break;
default:
break;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Error");
}
}
希望对你有帮助。应该看得懂吧、
{
try
{
DataGrid.HitTestInfo
hitInfo=dataGrid1.HitTest(e.X,e.Y);
switch(hitInfo.Type)
{
case DataGrid.HitTestType.Cell:
this.dataGrid1.Select(hitInfo.Row);
break;
default:
break;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Error");
}
}
希望对你有帮助。应该看得懂吧、
不是在行标头上单击,是单击记录
{
this.dataGrid1.IsSelected(this.dataGrid1.CurrentCell.RowNumber)=true;
}不知道行不行,试试看!
当ctrl按下时,如果单击过某行,就把这行变色,
如果ztrl没有按下,则单击哪行哪行就变色,其它行恢复原来的色,以上只是方法,要靠你自已实现
只能通过改变行底色来模拟为已经选中多行
其实也不难实现,很简单的一个算法,按CTRL时,单击时只要记下选中记录的ID同时改变底色就可以了
DataGrid不能实现多行选择。
=============================可以多行选择的。我做过多行删除,只不过需要按住ctrl点行头来选择。