Solved

StringGrid and combo box values passed to TButton.Onclick Event

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now