Solved

StringGrid and combo box values passed to TButton.Onclick Event

Posted on 2000-02-15
5
283 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 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