Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radiogroup and Viewing images

Status
Not open for further replies.

Lordkro

IS-IT--Management
Sep 3, 2011
4
0
0
I want to know if there is a way I can program a Radio group so, that when I select one that it will load that image which a selescted from an external file
 
Use the OnClick event of TRadioGroup. One of the properties of TRadioGroup is ItemIndex, as in "RadioGroup1.ItemIndex" that will tell you specifically which item in the TRadioGroup list was selected. '-1' is a 'valid' value for ItemIndex indicating either there are no items in the list or no specific item was selected (which should not be possible if decisions are made with the OnClick event).

Steve.
 
Yes I know how to use the radiogroup... I want to how would you use it to load and image file?? (.jpeg obviously)
 
Yes I know how to use the radiogroup... I want to know how would you use it to load an image file?? Meaning what will the code be??

What I want is the following:

//onclick event
if radiogroup.ItemIndex := 0
then
begin
img1. //And what to add here so that the image will load////
end;
 
If you want to use Jpg images, you have to declare JPEG in your uses clause. Otherwise it will crash. But all you do is..

Code:
uses
  Control, Graphics, JPEG;

...

procedure MyRadioGroupClick(Sender: TObject);
begin
  case MyRadioGroup.ItemIndex of
    0: Image1.Picture.LoadFromFile('C:\0.jpg');
    1: Image1.Picture.LoadFromFile('C:\1.jpg');
    2: Image1.Picture.LoadFromFile('C:\2.jpg');
  end;
end;

JD Solutions
 
Good, cuz I mis-spelled "Controls" instead of "Control" anyway, not like that part matters in the example but I always hate typos.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top