我现在用Datagrid控件做了一查询功能。怎么样才能把特殊记录用特定的颜色显示出来。

解决方案 »

  1.   

    换mshflexgrid控件比较方便做到。
      

  2.   

    我现在也在做这方面的程序,请 victorycyz(中海) 说得清楚一点
      

  3.   

    我现在也在做这方面的程序,请 victorycyz(中海) 说得清楚一点
      

  4.   

    mshflexgrid的属性中有很多控制不同地方色彩的,细到每个记录的每个字段。用if语句判断
    然后设置属性。自己添加一个控件看一下帮助。
      

  5.   

    用mshflexgrid方便
    Datagrid比较难
      

  6.   


    DateGrid1.DataSource = Adodc1
    Adodc1.ConnectionString = ConnSrv
    Adodc1.LockType = adLockBatchOptimistic
    Adodc1.RecordSource = "select* from TableName where A= "'" & 条件 &"'"
    Adodc1.Refresh
    前提:Adodc1 连上,
    strFile = App.Path & "\SYSSET.INI"
    '设置连接字符串
    ConnStr = "Provider=SQLOLEDB.1;" & _
            "Server=" & ReadIniFile("SYSTEM", "SQLServer", strFile) & ";" & _
            "Database=" & ReadIniFile("SYSTEM", "Database", strFile) & ";" & _
            "UID=" & ReadIniFile("SYSTEM", "UserID", strFile) & ";" & _
            "PWD=" & ReadIniFile("SYSTEM", "Password", strFile) & ";"
            
    Set ConnSrv = New ADODB.Connection
    '连接
    ConnSrv.Open ConnStr
      

  7.   

    With mshflexgrid
                For i = 1 To .rows - 1 Step 1
                    For j = 1 To .cols - 1
                        If (i Mod 2) = 0 Then
                        .row = i
                        .col = j
                        .CellBackColor = &HC0C0C0
                        .CellForeColor = vbBlack    
                        Else
                        .row = i
                        .col = j
                        .CellBackColor = H80000018
                        .CellForeColor = &H0 
                        End If
                    Next j
                Next i
        End With
    自己参考
      

  8.   

    VB中MSHFlexGrid控件的应用
     
     
     
     
    2003-4-24 15:15:46  
     
           应用心得                                  1)mshflexgrid控件 与 msflexgrid控件 的异同 mshflexgrid控件与adodc控件绑定,msflexgrid控件与data控件绑定。2)mshflexgrid控件的应用如果记录集已经在程序中产生,则可以不与adodc控件绑定,直接在mshflexgrid控件中显示数据,并且可以根据需要设置控件中行的颜色,如下例: public function datagrid_update() as boolean
    on error goto datagrid_update_err
    dim orarsrecordset as object
    dim adorsrecordset as new adodb.recordset
    dim lngdatediff as longcall ggetdata(const_generaltable_timeout_info, orarsrecordset)
    if not ado_databaseopen(dskattr, 1) then
    datagrid_update = false
    exit function
    end ifadorsrecordset.cursorlocation = aduseclient
    call adorsrecordset.open(const_vehicletable_recordset_queried, _
    mobjdatasource.connectionstring, , , adcmdtext)
    frmshownewdata.grdsaishin.colwidth(0) = 800
    frmshownewdata.grdsaishin.colwidth(1) = 2000
    frmshownewdata.grdsaishin.allowuserresizing = flexresizecolumns
    set frmshownewdata.grdsaishin.datasource = adorsrecordsetdim i as integer
    i = 0
    i = i + 1
    while not adorsrecordset.eof
    lngdatediff = datediff("n", adorsrecordset.fields("測位日時"), now)
    if lngdatediff > orarsrecordset.fields("gen_v_num").value then
    frmshownewdata.grdsaishin.row = i
    dim j as integer
    for j = 0 to frmshownewdata.grdsaishin.cols - 1
    frmshownewdata.grdsaishin.col = j
    frmshownewdata.grdsaishin.cellbackcolor = &h80ffff
    next
    end if
    i = i + 1
    adorsrecordset.movenext
    wend
    call ado_databaseclose
    datagrid_update = true
    exit function
    datagrid_update_err:
    call ado_databaseclose
    datagrid_update = false
    end function