Solved

Loading RadioButtons value to a String Grid.

Posted on 2000-02-15
7
188 Views
Last Modified: 2010-04-04
I have, on one form, a RadioGroup component, where depending on what entries your Registry has, will add a RadioButton for each one entries along with the captions. Here is the code for that:

procedure TSLESelectionForm.FormShow(Sender: TObject);
var
Registry: TRegistry;
Temp1, Temp2, Temp3, Temp4 : String;
begin
 Registry := TRegistry.Create;
 Registry.RootKey:=HKEY_LOCAL_MACHINE;
 Registry.OpenKey('\Software\Tester', False);
 Temp1 := Registry.ReadString('Location1');
 If Temp1 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location1'));
 Temp2 := Registry.ReadString('Location2');
 If Temp2 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location2'));
 Temp3 := Registry.ReadString('Location3');
 If Temp3 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location3'));
 Temp4 := Registry.ReadString('Location4');
 If Temp4 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location4'));
 Registry.CloseKey;
 Registry.Free;
end;

And this seems to work fine.

On another form, Mainform, is a stringgrid, that during SelectedCell, called the above form.

I need to pass which RadioButton on the above form was selected and put that text value in that area of the string grid, that first loaded that form, as the SLESelectionForm closes. I'm not sure how to even start this.
0
Comment
Question by:JPersinger
[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
7 Comments
 
LVL 3

Accepted Solution

by:
Alisher_N earned 50 total points
ID: 2524254
??
check rbSLELocation.ItemIndex - it is index of selected button, and
rbSLELocation.Items[ rbSLELocation.ItemIndex ] is string you need...
just assign it to your cell in strnggrid..
0
 
LVL 17

Expert Comment

by:inthe
ID: 2524318
Hi
this is probably the long way but
i added 2 more strings in registry ,called them row and col
then done like:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids,Registry;

type
  TmainForm = class(TForm)
    StringGrid1: TStringGrid;
    procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  mainForm: TmainForm;


implementation

uses Unit2;

{$R *.DFM}

procedure TmainForm.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
r : tregistry;
  begin
 R := TRegistry.Create;
 R.RootKey:=HKEY_LOCAL_MACHINE;
 R.OpenKey('\Software\Tester', False);
 R.WriteInteger('Row',Arow);
 R.WriteInteger('Col',Acol);
SLESelectionForm.ShowModal;
end;

end.



unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,registry,
  StdCtrls, ExtCtrls;

type
  TSLESelectionForm = class(TForm)
    rbSLELocation: TRadioGroup;
    procedure FormCreate(Sender: TObject);
    procedure rbSLELocationClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SLESelectionForm: TSLESelectionForm;
   a,b : integer;
implementation

uses Unit1;

{$R *.DFM}

procedure TSLESelectionForm.FormCreate(Sender: TObject);
var
Registry: TRegistry;
Temp1, Temp2, Temp3, Temp4 : String;
begin
 Registry := TRegistry.Create;
 Registry.RootKey:=HKEY_LOCAL_MACHINE;
 Registry.OpenKey('\Software\Tester', False);
 Temp1 := Registry.ReadString('Location1');
 If Temp1 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location1'));
 Temp2 := Registry.ReadString('Location2');
 If Temp2 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location2'));
 Temp3 := Registry.ReadString('Location3');
 If Temp3 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location3'));
 Temp4 := Registry.ReadString('Location4');
 If Temp4 > '' then rbSLELocation.Items.Add(Registry.ReadString('Location4'));
 Registry.CloseKey;
 Registry.Free;
end;

procedure TSLESelectionForm.rbSLELocationClick(Sender: TObject);
var
r : tregistry;
i : integer;
  begin
 R := TRegistry.Create;
 R.RootKey:=HKEY_LOCAL_MACHINE;
 R.OpenKey('\Software\Tester', False);
 a := r.ReadInteger('Row');
 b := r.ReadInteger('Col');
 i := rbSLELocation.ItemIndex;
 mainform.StringGrid1.Cells[b,a] := rbSLELocation.Items.Strings[i];
 SLESelectionForm.Close;
end;

end.
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2524357
why add extra junk to registry ???
the same can be done via couple of extra VARs inside a programm...
0
Industry Leaders: 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!

 
LVL 17

Expert Comment

by:inthe
ID: 2524394
i know i was just there ..
   (in the registry i mean ;-)
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2524637
I think Alisher has it...
0
 

Author Comment

by:JPersinger
ID: 2524678
I agree with rwilson. Alisher N thanks.
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2526237
welcome everybody ;-))
(just want that T-shirt, you know ;-))
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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 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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

622 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