Link to home
Start Free TrialLog in
Avatar of drnadeem
drnadeem

asked on

Stringgrid value validation

When I want to enter a value into a string grid cell (eg: StringGrid1.Cells[2,1]) I want to check whether that same value exists either in the same column  or in the same row. It's some kind of a validation process whereby, I would be able to assign some value to the cell if only the same value does not exist in the same column or row.

sorry for my English.

thnks
Avatar of kretzschmar
kretzschmar
Flag of Germany image

well, you could use

//for same row
if stringgrid1.rows[rowindex].IndexOf('VALUE') > -1 then
  showmessage('Exists Already');

//for same column
if stringgrid1.cols[colindex].IndexOf('VALUE') > -1 then
  showmessage('Exists Already');

just as kickoff
(just clear and save your current input before validating)

not sure about syntax->just from head

meikl ;-)
working sample may follow . . .
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterLarsen
PeterLarsen

I haven't read the entire question with comments, but if you want to search through a row or a column i guess you can use IndexOf. StringGrid1.Rows[xx].IndexOf('search text');
And again, i don't know whether this have been suggested by kretzs.. !