感谢您使用微软产品。 Datagird本身并没有提供能够修改某一行记录颜色的方法,但是您可以通过以下方法来模拟改变某一行的颜色:首先,您需要在Form上画一个TextBox,然后把选中他,把他的Appenar 属性设置为 0 – flat,然后把它的BorderStyle属性设置为 0-none,再把他的Visible属性设置为false,BackColor属性设置为您需要的颜色。然后复制他,再粘贴。在是否创建控件数组的对话框中选择是。然后创建多个TextBox,使得其数量和DataGrid的列数一样,然后执行下列代码:For i = 0 To DataGrid1.Columns.Count - 1
        Text(i).Visible = True
        Text(i).Appearance = 0
        Text(i).BorderStyle = 0
        Text(i).Width = DataGrid1.Columns(i).Width
        Text(i).Height = DataGrid1.RowHeight
        Text(i).Top = DataGrid1.RowTop(2) ‘第一行数据背景变成红色
        If DataGrid1.Columns(i).Left <> 0 Then
          Text(i).Left = DataGrid1.Columns(i).Left + DataGrid1.Left
        Else
          Text(i).Visible = False
        End If
        Text(i).BackColor = RGB(255, 0, 0)
        Text(i).Text = DataGrid1.Columns(i).Text
Next i 请注意,您必须在Datagrid的ColResize, RowResize, Scroll事件中执行类似代码,在修改记录内容时将其后面的Datagrid中的实际内容修改掉。Visual Basic 6.0中的Datagrid控件有很大的局限性,您可以使用Visual Studio.NET中的Datagrid控件来实现您需要的功能&shy;,您可以参考以下文章:
Introduction to the Windows Forms DataGrid Control (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconIntroductiontotheDataGridControl.asp )来了解.NET中Datagrid的使用。 微软全球技术中心 VB技术支持
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。