Solved

component one true dbgrid v7.0

Posted on 2001-09-04
7
1,251 Views
Last Modified: 2012-06-27
Say I have a column of figures, how do I go about picking say the worst or best figure in that column and changing its colour.  I know how to change the colours, I need to know how to find the cell and determine whether the cell is the best one or the worst one.

cheers,

ray.

ps. I am using the oledb version
0
Comment
Question by:raybetts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6452914
What do you mean by best one or worst one? Ok, you would need to do this, from the FetchCellStyle Event. Something like this:

Private Sub TDBGrid1_FetchCellStyle(ByVal Condition As Integer, ByVal Split As Integer, Bookmark As Variant, ByVal Col As Integer, ByVal CellStyle As TrueOleDBGrid70.StyleDisp)

If TDBGrid1.Columns(0).CellText(Bookmark) = 0 Then
    CellStyle.ForeColor = vbBlue
ElseIf TDBGrid1.Columns(0).CellText(Bookmark) > 200 Then
    CellStyle.ForeColor = vbRed
End If

End Sub

0
 
LVL 1

Author Comment

by:raybetts
ID: 6453804
By picking, I mean locating, sorry for my incorrect use of english.

How does fetchcellkstyle get called?
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6455522
The event occurs when the grid is to refresh cell data, for a column(s), for which, the FetchStyle property is set to True.




0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:raybetts
ID: 6456437
valli_an

I now understand how the methods and events work, but how do I scan a particular column and work out the highest or lowest fig

eg

loop till column(x) = end 'loop a given column
   
   'find worst fig and change colour
   if row.figure = lowest then row.forecolour = red

obviously the syntax above is incorrect, but hopefully it gives you an idea of what I want to do.


0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 50 total points
ID: 6456602
How are you displaying the data to grid. Is it using a bound or unbound method.

You should be able to find it using the underlying data, say, recordset or Xarraydb or whatever.

Otherwise, loop through the columns collection like this:

Dim mMaxRow As Long, mMaxVal, mMinVal, mCurVal
if Col = 0 Then 'or whatever column
  mMaxRow = rs.RecordCount
  mMaxVal = 0
  mCurVal = 0

  TDBGrid1.Row = 0
  mMinVal = TDBGrid1.Columns(0).Value

  For j = 0 To mMaxRow - 1
   TDBGrid1.Row = j
   mCurVal = TDBGrid1.Columns(0).Value
   'your code to get max. and min. values
   if mCurVal > mMaxVal Then
       mMaxVal = mCurVal
       'change style here.
   elseif mCurVal < mMinVal Then
       mMinVal = mCurVal            
   End If
  Next                    
End If

Or, if you could do in table, using query it could be better, and faster. This would be very slow, since every time it fetches a cell, it will go through this code.
0
 
LVL 1

Author Comment

by:raybetts
ID: 6457089
the slowness of looping was the thing I was worried about and I was hoping the grid would have had a neat trick to combat this!  Still cant complain, could still be using the std vb grid!!!!

Thanks for the help.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6459450
You're welcome.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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