Lazarus

Programming => General => Topic started by: pixelink on July 02, 2020, 09:05:30 pm

Title: [SOLVED] Quick Q - Not Getting Correct Data When Selecting Cell/Row
Post by: pixelink on July 02, 2020, 09:05:30 pm
Got a weird issue and not sure what gives.

Using StringGrid.
I have 1 fixed row (header) - 3 Columns (one is Grid Button)
2 Rows of actual data

When using the grid button, it returns the data fine of the appropriate row data.

But when using event "OnSelectCell"

It retuns the wrong data.

So, if I click on a cell in row 1, it teturns data from row 2
And visa-versa - Returns data from row 1 if I click on cell in row two.

Again... using same code, it works fine on the grid button

CODE:

Code: Pascal  [Select][+][-]
  1. lbStatus.Caption:=StringGrid1.Cells[2,StringGrid1.Row]+ '\';

What is going on?

Thanks for any help.
Title: Re: Quick Q - Not Getting Correct Data When Selecting Cell/Row
Post by: jamie on July 02, 2020, 09:27:37 pm
miss use of the event I am afraid..

 If you look you have aCOL, AROW etc..

and a Boolean;;

 The ACOL and aROW is the cell you just clicked into
the Boolean allows you to instruct the grid to accept it.

 but in this case if you need to use it directly you use the indexes given to you in the event call not from the class body
Title: Re: Quick Q - Not Getting Correct Data When Selecting Cell/Row
Post by: pixelink on July 02, 2020, 10:04:34 pm
miss use of the event I am afraid..

 If you look you have aCOL, AROW etc..

and a Boolean;;

 The ACOL and aROW is the cell you just clicked into
the Boolean allows you to instruct the grid to accept it.

 but in this case if you need to use it directly you use the indexes given to you in the event call not from the class body

Okay, I mostly get it.
So, how do i fix it so that I am reference the correct row (col - row)?
Title: Re: Quick Q - Not Getting Correct Data When Selecting Cell/Row
Post by: jamie on July 02, 2020, 10:10:02 pm
Hmm
in the OnSelectCell event;
Code: Pascal  [Select][+][-]
  1. lBStatus.caption := StringGrid1.Cells[2, AROW] +'\';
  2.  
Title: Re: Quick Q - Not Getting Correct Data When Selecting Cell/Row
Post by: pixelink on July 02, 2020, 10:16:35 pm
Hmm
in the OnSelectCell event;
Code: Pascal  [Select][+][-]
  1. lBStatus.caption := StringGrid1.Cells[2, AROW] +'\';
  2.  

Oh, I knew that... I just for got about it.

Thanks for the help Jamie
TinyPortal © 2005-2018