StringGrid with Open Dialog

I have a string grid on a form. In the first row, 0, I have a path (a string value, of course) value listed there. I need to do a 'OnCellSelect' for the 2nd row and execute an OpenDialog. The initial dir of the OpenDialog needs to be that of the first row, 0, that was selected. I don't understand the syntax here? Any ideas?
routerboy309Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
Do it like this:

procedure Grid1SelectCell(Sender: TObject; ACol, ARow: Longint; var CanSelect: Boolean);

begin
  if ARow = 1 then
    begin
      OpenDialog1.InitialDir := Grid1.cells[ACol, 0];
      OpenDialog.Execute;
    end;
end;

Does that help?

Cheers,

Raymond.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
routerboy309Author Commented:
Something is weird....Using that produces the inital directory to be the application location. I may of told you incorrect...Rows, going across, right. Cols going up and down.

First Right Row is the path string...I changed your code to be

if ACol = 1 then
    begin
      OpenDialog2.InitialDir := ListGrid.Cells[AROW, 0];
      OpenDialog2.Execute;
    end;

and I still get unpredicted results...
0
rwilson032697Commented:
Nope - Cells is always referenced as cells[col, row].

Dows row 0 hold you paths? What gets set if you follow it in the debugger?

Cheers,

Raymond.

0
routerboy309Author Commented:
debugger showed I had the incorrect settings for the grid...Here is my correction and it works.

if ACOL = 1 then
    begin
      OpenDialog2.InitialDir := ListGrid.Cells[0, AROW];
      OpenDialog2.Execute;

Thanks
0
routerboy309Author Commented:
One more thing... After the path is added, and the OpenDialog opens to the correct path, I can see my files. When I click on which file I need, I need the name of the file to return to the stringgrid to match the same line as the path...Is there a simple solution for this?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.