hello please help me on how to put indicator on flexgrid is this possible?,...if i have new added data on my flexgrid then it point to the newly added data can you help how to do this...hoping for your positive responds..thanks in advance

Hi!

If you want a "sign" in the line (the way Microsoft Access does), you can make a small picture (in "bmp" or "ico" format, I supose), then load this picture all times user change the line, or, if you use datacontrol, all times user move to next / prior record (in this case, you must use AbsolutePosition property to sure the record you poit to is the same DataControl is pointing to).

*** IF YOU AREN'T USING DATACONTROL IN YOUR FORM ***

Private Sub MSFlexGrid1_Click()

  MSFlexGrid1.Col = 0
  Set MSFlexGrid1.CellPicture = LoadPicture("C:\LOGO.BMP")
  
End Sub

*** IF YOU'RE USING DATACONTROL IN YOUR FORM ***

Private Sub Data1_Reposition()

  With MSFlexGrid2
    If .Rows > 0 Then
      .Col = 0
      .Row = Data1.Recordset.AbsolutePosition + 1
      Set .CellPicture = LoadPicture("C:\LOGO.BMP")
    End If
  End With

End Sub

Note: you want to make a public variable storing temporarily the line you last point to, cause the user can move not always to the next record, but to the last, prior or first record in the table, or click in any line of the grid itself.
To ensure this function works perfectly, you need to test this variable and delete the image from the last line user point to:

.Col = 0     
      .Row = nUltLinha   'nUltLinha is the public variable that holds the last line pointed
      Set .CellPicture = Nothing   'Setting picture to nothing make it disappear from the grid

I hope this helps.
Any doubt at this code, keep track and ask for...

Sidnei

Hi
Exactly the way Sidnei has told. This is the way you can add icons to your flex grid.
Happy Programming

Hi,

Or else, Just simply change the BackColor of newly added row...
Say You have added new row to the grid as the last row, then use this code:

Dim i As Integer
With Grd
    .Row = .Rows-1
    For i = 0 To .Cols-1
        .Col = i
        .CellBackColor = vbBlue
        .CellForeColor = vbWhite
    Next
    .TopRow = .Row
End With

Regards
Veena

Thanks, Veena!
Your solution make the entitre line "indicated" and are faster, cause don't need to load any picture to the memory...
The one I presented put a little icon in the beggining of the line, so, if the user don't pay attention, sometimes it will not be viewed...

I think with this steps jemz can:
1. Put a tinny picture in the first column of a line;
2. Change the background and font color of the entire line;
3. Or join the two solution presented, changing the background color only for the first column of the desired line!


And then, jemz, any suggestion helped you out?


Sidnei

Hi
The suggestions are very well
I am sure one of them will help jemz in solving his question surely.
Happy Programing

Hi Sidnei,

Welcome.. Changing the BackColor of entire row is faster and less load on memory..
But the only thing we need to Take Care here is, When the User Adds One more row (If the rows are not being added sequentially) , We need to Reset the back/fore color of the previously added row. This can be done by keeping a Form-Level variable, to indicate which row was previously Painted...

Regards
Veena

hello thanks for the reply and for helping me...i will try this code if this work and i will let you know..more power to you

hello i tried your code it works but all the data i added. is highlighted or turn to cellbackcolor=blue and cellforecolor= white...but i want only the currently be indicate or to be color.here is my code please help me how to insert your code..hoping for your positive responds.and correct me if im wrong with my trappings.

Private Sub cmdadd_Click()




 
 

    
    If Trim(txtLname.Text) <= "A" Then
        MsgBox "Invalid , in your last name"
        txtLname.SelStart = 0
        txtLname.SetFocus
        txtLname.SelLength = Len(txtLname.Text)
        Exit Sub
        End If
    
      
         

    
    If Trim(txtFname.Text) <= "A" Then
        MsgBox "invalid, in the firstname"
        txtFname.SelStart = 0
        txtFname.SetFocus
        txtFname.SelLength = Len(txtFname.Text)
        Exit Sub
        End If

   
          
 
 
      
    If Trim(txtMname.Text) <= "A" Then
        MsgBox "Invalid,middle name"
        txtMname.SelStart = 0
        txtMname.SetFocus
        txtMname.SelLength = Len(txtMname.Text)
        Exit Sub
      
    ElseIf Len(Trim(txtMname.Text)) <> 1 Then
      MsgBox "Middle inital only"
      txtMname.SelStart = 0
      txtMname.SetFocus
      txtMname.SelLength = Len(txtMname.Text)
      Exit Sub
      End If

   
        
        
        If Trim(txtMname.Text) = "" Then
             MsgBox "you have not inputed Middle name", vbInformation
             txtMname.SelStart = 0
             txtMname.SetFocus
             txtMname.SelLength = Len(txtMname.Text)
             Exit Sub
      
         End If
 
        
   
   
   
         If (txtaddres.Text) = "" Then
             MsgBox "you have not inputed Addres", vbInformation
             txtaddres.SelStart = 0
             txtaddres.SetFocus
             txtaddres.SelLength = Len(txtaddres.Text)
             Exit Sub
             End If


           
            
 If (Val(txtAge.Text)) <= 0 Then
     MsgBox "that is not an age", vbCritical
     txtAge.SelStart = 0
     txtAge.SetFocus
     txtAge.SelLength = Len(txtAge.Text)
     Exit Sub

        
     
        
     
  ElseIf (Val(txtAge.Text)) < 18 Or (Val(txtAge.Text)) > 90 Then
     MsgBox "Invalid input Your not qualified voter", vbCritical
     txtAge.SelStart = 0
     txtAge.SetFocus
     txtAge.SelLength = Len(txtAge.Text)
     Exit Sub
     End If
     
    
    
    pn = Trim(txtc.Text) + "-" + Trim(txtPn.Text)
    adress = Trim(Me.lbladdress.Caption)
    vidno = Trim(lblvidno.Caption)
    last = Trim(txtLname.Text)
    first = Trim(txtFname.Text)
    middle = Trim(Me.txtMname)
    address = Trim(Me.txtaddres)
    age = Val(txtAge.Text)
   


 

 grd.TextMatrix(grd.Rows - 1, 0) = vidno
 grd.TextMatrix(grd.Rows - 1, 1) = pn
 grd.TextMatrix(grd.Rows - 1, 2) = last
 grd.TextMatrix(grd.Rows - 1, 3) = first
 grd.TextMatrix(grd.Rows - 1, 4) = middle
 grd.TextMatrix(grd.Rows - 1, 5) = address
 grd.TextMatrix(grd.Rows - 1, 6) = age
 
 grd.Rows = grd.Rows + 1

Hi,

Try This :

Dim n As Integer
grd.TextMatrix(grd.Rows - 1, 0) = vidno
grd.TextMatrix(grd.Rows - 1, 1) = pn
grd.TextMatrix(grd.Rows - 1, 2) = last
grd.TextMatrix(grd.Rows - 1, 3) = first
grd.TextMatrix(grd.Rows - 1, 4) = middle
grd.TextMatrix(grd.Rows - 1, 5) = address
grd.TextMatrix(grd.Rows - 1, 6) = age

With Grd
    .Row = .Rows-1
    For n = 0 To .Cols-1
        .Col = n
        .CellBackColor = vbBlue
        .CellForeColor = vbWhite
    Next
    .TopRow = .Row
End With
 grd.Rows = grd.Rows + 1

Regards
Veena

hi i tried again your code the problem that all data are highlighted...i want only newly added data will be highlighted so that the user may recognize that the new data is added...example i add this shane marie M. Jackson so when this is display in flexgrid this will be highlighted .so if i input another data , shane marie M. Jackson will not be highlighted anymore, only the newly added data will highlighted...please help me on this is this possible in the flexgrid?...hoping for your positive responds.

hi i tried again your code the problem that all data are highlighted...i want only newly added data will be highlighted so that the user may recognize that the new data is added...example i add this shane marie M. Jackson so when this is display in flexgrid this will be highlighted .so if i input another data , shane marie M. Jackson will not be highlighted anymore, only the newly added data will highlighted...please help me on this is this possible in the flexgrid?...hoping for your positive responds.

hello but everytime i add data all data will be color...ahm is this possible exmple i will add this shane mariah then this will display on my flexgrid so this will be highlighted but after i input another data the newly data only will be highlighted and then shane mariah will not be hightlighted anymore in my flexgrid...can you help me on this?..so that the user can indicate the newly added data...please hlep me on this..hoping for your positive responds.

Jemz,
two different situations:

1. The newly added data is ever the last line;
2. The newly added data is wherever in the grid.

In the first case, simply code the last line from grid to become backcolor white and forecolor black again, it's a quite simple. After do that, add the new line in the last position and change the backcolor to blue and forecolor to white.

But for the second case, you'll NEED to loop the entire grid, changing ALL backcolor and forecolor lines to white and black respectively, and then add your new line in backcolor blue and forecolor white.

Try using the code snippet Veena show you, in case of doubts write again.


Cheers,
Sidnei

hello but everytime i add data all data will be color...ahm is this possible exmple i will add this shane mariah then this will display on my flexgrid so this will be highlighted but after i input another data the newly data only will be highlighted and then shane mariah will not be hightlighted anymore in my flexgrid...can you help me on this?..so that the user can indicate the newly added data...please hlep me on this..hoping for your positive responds.

ahm can you show me how to make this loop ....i am confuse right now please help me..thanks in advance.hoping for your positive responds

Take a look at this:

Dim nCont As Integer, nAux As Integer


'IF YOU DON'T MIND "WITH" MEANS, GOOGLE THIS: "VB6 WITH"
With grdDados

  'LOOP THROUGH EVERY LINE
  For nCont = 1 To .Rows - 1
    For nAux = 1 To .Cols - 1
      .Row = nCont
      .Col = nAux
      .CellBackColor = vbWhite
      .CellForeColor = vbBlack
    Next
  Next
    
  'HIGHLIGHT A SPECIFIED LINE
  .Row = 3
  For nAux = 1 To .Cols - 1
    .Col = nAux
    .CellBackColor = vbBlue
    .CellForeColor = vbWhite
  Next

End With

REMARKS:
- the above code suppose that you have a FIXED ROW line and a FIXED COLUMN column; if you don't have, please change the counter to initiate in 0 either 1;
- the 3 assigned to the ROW property is only demonstrative. Should be the line number you want to highlight. If is the last line, you can use .Row = .Rows - 1 .

Try it.
Sidnei

so where do i put your code thanks for the patience...

Dim n As Integer

grd.TextMatrix(grd.Rows - 1, 0) = vidno

grd.TextMatrix(grd.Rows - 1, 1) = pn

grd.TextMatrix(grd.Rows - 1, 2) = last

grd.TextMatrix(grd.Rows - 1, 3) = first

grd.TextMatrix(grd.Rows - 1, 4) = middle

grd.TextMatrix(grd.Rows - 1, 5) = address

grd.TextMatrix(grd.Rows - 1, 6) = age

With Grd

.Row = .Rows-1

For n = 0 To .Cols-1

.Col = n

.CellBackColor = vbBlue

.CellForeColor = vbWhite

Next

.TopRow = .Row

End With

grd.Rows = grd.Rows + 1

Replace the code between "With grd" and "End With" with the one I wrote...

And replace the line .Row = 3 with .Row = .Rows - 1 , seems to me you're adding the new record at the last position on the grid.

The code grd.Rows = grd.Rows + 1 must be before the grd.TextMatrix(grd.Rows - 1, 0) = ... block, otherwise you may lost the last record you put on the grid.

And, of course, the code I write points to a "grdDados" component, you'll need to adapt it for your "Grd" - names are different but same usage.

Sidnei

hi sidnei thank you so much at last i found my answer..thank you so much it really works ...more power to you....ahmm by the way im confuse by the row and rows what is there difference of them

Are properties of the grid, and means:

Row = the active row, the row selected by the user or set manually by the program. Indicates the row selected in the grid

Rows = the number of rows (quantity) displayed in the grid.


Note that Rows means QUANTITY, while ROW means INDEX OF A ROW, so, if the grid has 10 rows, the Rows property has a value of 10, while the Row property has values between 0 and 9 (ten values) indicating each individual row. This is the need of ROW = ROWS - 1: then index is always the number of rows less 1.

Right?

Sidnei

Row

hi sidnei thank you so much at last i found my answer..thank you so much it really works ...more power to you....ahmm by the way im confuse by the row and rows what is there difference of them

thank you for the reply sindei and thank you also for always solving my problems....more power to you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.