Solved

StringGrid and combo box values passed to TButton.Onclick Event

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

10 Experts available now in Live!

Get 1:1 Help Now