rt

解决方案 »

  1.   

    你可以在通过设计SelectionForeColor,SelectionBackColor等属性实现.
    在Click事件中用HitTest测试一下点是哪行,然后用DataGrid.Select(n)方法选中该行.
      

  2.   

    你可以在通过设计SelectionForeColor,SelectionBackColor等属性实现.
    在Click事件中用HitTest测试一下点是哪行,然后用DataGrid.Select(n)方法选中该行.
      

  3.   

    private void datagrid1_CurrentCellChanged(object sender, System.EventArgs e)
    {

    datagrid1.CurrentCell = new DataGridCell(datagrid1.CurrentCell.RowNumber,0);  
    datagrid1.Select(datagrid1.CurrentCell.RowNumber); 
    }
      

  4.   

    兄弟见意你用Infragistics的UltraGird的第三方控件
      

  5.   

    实现起来有点困难,
    要重写dataGrid 的 DataGridTextBoxColumn 类
      

  6.   

    DataGridTextBoxColumn?我的grid中并没有textbox呀?
      

  7.   

    改字体与click有什么关系呀,楼上的兄弟.
      

  8.   

    举例说明:
    private void Gridaaa_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem )
    {
    e.Item.Attributes.Add("onmousedown","this.style.backgroundColor='Silver'");

    }
    }
      

  9.   

    this.style.backgroundColor中的backgroundColor可用以下替换:backgroundColor 设置或获取对象内容后的颜色。 
    color color 设置或获取对象文本的颜色。  
    cursor cursor 设置或获取当鼠标指针指向对象时所使用的鼠标指针。 
    fontFamily 设置或获取对象文本所使用的字体名称。 
    fontSize 设置或获取对象文本使用的字体大小。 
    fontStyle 设置或获取对象的字体样式,如斜体、常规或倾斜。 
    fontVariant 设置或获取对象文本是否以小型大写字母显示。 
    fontWeight 设置或获取对象的字体宽度。 
    height 设置或获取对象的高度。 
    imeMode 获取输入方法编辑器(IME)的状态。
      

  10.   

    dataGrid1.SelectionForeColor=Color.Red;
    MessageBox.Show(dataGrid1.SelectionForeColor.Name.ToString());
      

  11.   

    大大门,还是找不到方法来设置selection的字体呀?
      

  12.   

    直接从DataGrid中的属性中去设置它,不就行了吗??
      

  13.   

    ‘重写DataGridTextBoxColumn
    Private Class DataGridColoredTextBoxColumn
            Inherits DataGridTextBoxColumn  '继承接口        Private _parentDagaGrid As DataGrid        Public Sub New(ByRef parentName As DataGrid)
                _parentDagaGrid = parentName
            End Sub        Private Function GetText(ByVal Value As Object) As String            If TypeOf (Value) Is System.DBNull Then
                    Return ""
                ElseIf Value Is Nothing Then
                    Return ""
                Else
                    Return Value.ToString
                End If        End Function
            Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)
                Dim text As String
                Dim iCount As Integer            Try
                    text = GetText(GetColumnValueAtRow(source, rowNum)).Trim            Catch ex As Exception
                Finally
                    If Me._parentDagaGrid.CurrentRowIndex = rowNum Then
                        MyBase.PaintText(g, bounds, "", Brushes.Green, foreBrush, alignToRight)   ’画背景
                        g.DrawString(text, New Font("宋体", 14), Brushes.Red, bounds.X + 2, bounds.Y + 2)   ’画字,设置字体及其颜色
                    Else
                        MyBase.PaintText(g, bounds, text, backBrush, foreBrush, alignToRight)
                    End If            End Try
            End Sub    End Class
    至于datagrid的选中操作这里就不写了。