Solved

Paint a row in Datagrid

Posted on 2002-04-28
5
583 Views
Last Modified: 2006-11-17
Hi Everyone,

How can i Paint a row in Datagrid ?

10x
0
Comment
Question by:mosheshitrit
5 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 6974787
Hi Mosheshirit,

you can use a invisible pictur box and a snippet

Sub ColorRow(pic As PictureBox, grd As MSFlexGrid, _
iRow As Integer, iBackColor As Integer, Optional Clear As Variant)
'sText As String,iForeColor As Integer,
    Dim iCol As Integer
    grd.Row = iRow
    pic.ForeColor = QBColor(iForeColor)
    pic.BackColor = QBColor(iBackColor)
    For iCol = grd.FixedCols To grd.Cols - 1
        If IsMissing(Clear) Then
            grd.Col = iCol
            pic.Width = grd.ColWidth(grd.Col) + 50
            pic.Height = grd.RowHeight(grd.Row) + 50
            pic.Cls
            pic.Picture = LoadPicture("")
            pic.CurrentX = Screen.TwipsPerPixelX
            pic.CurrentY = Screen.TwipsPerPixelY
            'pic.Print sText
            Set grd.CellPicture = pic.Image
            'grd.Text = sText
        Else
            Set grd.CellPicture = Nothing
        End If
    Next
End Sub

from another coder(Yoram Shechori)

HTH:O)Bruintje
0
 

Author Comment

by:mosheshitrit
ID: 6975044
To bruintje,

Will i bw able to see painted row text ?

Maybe an API ?

Thanks
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6975192
had to test it first so

Private Sub Command1_Click()
  ColorRow Picture1, MSFlexGrid1, 1, 2, 13, "test"
End Sub

Sub ColorRow(pic As PictureBox, grd As MSFlexGrid, _
iRow As Integer, iBackColor As Integer, _
iForeColor As Integer, sText As String, Optional Clear As Variant)
   Dim iCol As Integer
   grd.Row = iRow
   pic.ForeColor = QBColor(iForeColor)
   pic.BackColor = QBColor(iBackColor)
   For iCol = grd.FixedCols To grd.Cols - 1
       If IsMissing(Clear) Then
           grd.Col = iCol
           pic.Width = grd.ColWidth(grd.Col) + 50
           pic.Height = grd.RowHeight(grd.Row) + 50
           pic.Cls
           pic.Picture = LoadPicture("")
           pic.CurrentX = Screen.TwipsPerPixelX
           pic.CurrentY = Screen.TwipsPerPixelY
           pic.Print sText
           Set grd.CellPicture = pic.Image
           grd.Text = sText
       Else
           Set grd.CellPicture = Nothing
       End If
   Next
End Sub

this will paint the cell and add the text added in the commandbuttonclick it's a complete function if you use hte clear it will clear out the cell, else it will use the colors and the text could be a variable of course

HTH:O)Bruintje
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7670397
Hi mosheshitrit,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept bruintje's comment(s) as an answer.

mosheshitrit, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8092562
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now