?
Solved

StringGrid and combo box values passed to TButton.Onclick Event

Posted on 2000-02-15
5
Medium Priority
?
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

743 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