JPersinger
asked on
Loading RadioButtons value to a String Grid.
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_LOC AL_MACHINE ;
Registry.OpenKey('\Softwar e\Tester', False);
Temp1 := Registry.ReadString('Locat ion1');
If Temp1 > '' then rbSLELocation.Items.Add(Re gistry.Rea dString('L ocation1') );
Temp2 := Registry.ReadString('Locat ion2');
If Temp2 > '' then rbSLELocation.Items.Add(Re gistry.Rea dString('L ocation2') );
Temp3 := Registry.ReadString('Locat ion3');
If Temp3 > '' then rbSLELocation.Items.Add(Re gistry.Rea dString('L ocation3') );
Temp4 := Registry.ReadString('Locat ion4');
If Temp4 > '' then rbSLELocation.Items.Add(Re gistry.Rea dString('L ocation4') );
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.
procedure TSLESelectionForm.FormShow
var
Registry: TRegistry;
Temp1, Temp2, Temp3, Temp4 : String;
begin
Registry := TRegistry.Create;
Registry.RootKey:=HKEY_LOC
Registry.OpenKey('\Softwar
Temp1 := Registry.ReadString('Locat
If Temp1 > '' then rbSLELocation.Items.Add(Re
Temp2 := Registry.ReadString('Locat
If Temp2 > '' then rbSLELocation.Items.Add(Re
Temp3 := Registry.ReadString('Locat
If Temp3 > '' then rbSLELocation.Items.Add(Re
Temp4 := Registry.ReadString('Locat
If Temp4 > '' then rbSLELocation.Items.Add(Re
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.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
why add extra junk to registry ???
the same can be done via couple of extra VARs inside a programm...
the same can be done via couple of extra VARs inside a programm...
i know i was just there ..
(in the registry i mean ;-)
(in the registry i mean ;-)
I think Alisher has it...
ASKER
I agree with rwilson. Alisher N thanks.
welcome everybody ;-))
(just want that T-shirt, you know ;-))
(just want that T-shirt, you know ;-))
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(Send
var CanSelect: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
mainForm: TmainForm;
implementation
uses Unit2;
{$R *.DFM}
procedure TmainForm.StringGrid1Selec
ARow: Integer; var CanSelect: Boolean);
var
r : tregistry;
begin
R := TRegistry.Create;
R.RootKey:=HKEY_LOCAL_MACH
R.OpenKey('\Software\Teste
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:
private
{ Private declarations }
public
{ Public declarations }
end;
var
SLESelectionForm: TSLESelectionForm;
a,b : integer;
implementation
uses Unit1;
{$R *.DFM}
procedure TSLESelectionForm.FormCrea
var
Registry: TRegistry;
Temp1, Temp2, Temp3, Temp4 : String;
begin
Registry := TRegistry.Create;
Registry.RootKey:=HKEY_LOC
Registry.OpenKey('\Softwar
Temp1 := Registry.ReadString('Locat
If Temp1 > '' then rbSLELocation.Items.Add(Re
Temp2 := Registry.ReadString('Locat
If Temp2 > '' then rbSLELocation.Items.Add(Re
Temp3 := Registry.ReadString('Locat
If Temp3 > '' then rbSLELocation.Items.Add(Re
Temp4 := Registry.ReadString('Locat
If Temp4 > '' then rbSLELocation.Items.Add(Re
Registry.CloseKey;
Registry.Free;
end;
procedure TSLESelectionForm.rbSLELoc
var
r : tregistry;
i : integer;
begin
R := TRegistry.Create;
R.RootKey:=HKEY_LOCAL_MACH
R.OpenKey('\Software\Teste
a := r.ReadInteger('Row');
b := r.ReadInteger('Col');
i := rbSLELocation.ItemIndex;
mainform.StringGrid1.Cells
SLESelectionForm.Close;
end;
end.