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?
 
rwilson032697Connect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.