Solved

StringGrid and combo box values passed to TButton.Onclick Event

Posted on 2000-02-15
5
287 Views
Last Modified: 2010-04-04
I have a StringGrid, with four columns. The first column is holding a path (like \\TestMachine) and the second column is holding a file name (like test.exe).
Once the info of the grid is 'saved', you have an option to select different programs that show up in a Combobox (looking at the second column of the grid).
Since each Column 1 may have a different path stored, I need a button, when selected to find the path stored in the correct column number and add that path to the file name found in the combobox, before the application trys to run. I do not want the path to show up in the combo box.
I have this in the ComboBox Drop Down-

with MainForm.ListGrid do begin
       ComboBox1.Items.Assign(MainForm.ListGrid.Cols[2])
end;

I do I search the grid until it finds the file that is now in the ComboBox and append it to the file name?
0
Comment
Question by:routerboy309
5 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 2523660
can you give more information? What is your real q'n?

Zif.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 2523687
I think I understand your q'n :

No, you don't need to search for the file. You can use the index of the combobox as the row-value of the grid: eg :

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  showmessage(stringGrid1.Cells[0,combobox1.itemindex])
end;

Regards, Zif
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2523693
What about doing this:

iIndex := -1;
SelectedFile := ListGrid.Cells[1, <index>];
FOR n := 0 TO (ListGrid.RowCount - 1)
DO
  IF ListGrid.Cells[1, n] = SelectedFile
  THEN
    iIndex := n;

IF iIndex <> -1
THEN
BEGIN
  ExeFile := ListGrid.Cells[0, iIndex] + SelectedFile;
  //Run your file
END
ELSE
  MessageDlg('Unable to locate path', mtWarning, [mbOk], 0);

All you have to do is cporrectly setup SelectedFile and maybe add some path checking when you add the path to the filename and it should work.

It also makes the assumption that you have NO DUPLICATED items in the second column.

The Neil
0
 
LVL 2

Expert Comment

by:aubs
ID: 2523716
put this in the combobox change event

procedure Tmainform.ComboBox1Change(Sender: TObject);
var
      path: string;
begin
      path:= ListGrid.Cells[1,combobox1.itemindex] + '\'+ combobox1.text;
end;

Aubs
0
 

Author Comment

by:routerboy309
ID: 2523717
I was almost done with the first response ZifNab asked for, but ZifNab answered it. Thanks for the VERY fast response.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question