arkadaşlar bir yerde tıkandım kaldım.
şimdi program bi şekilde bir sayı üretip edit1.textin içerisine sayı üretiyor.
benim ekranda 600 tane checkbox var
o sayı kadar checkboxın ekranda gözükmesini istiyorum.
otomatik o kadar sayı kadar checkbox üreten bir programda olabilir. o kadar checkboxın görünürlüğünü açanda olabilir. lütfen yardımcı olun.
NOT: memoya ben checkbox1.viseble:=true checkbox2.viseble:=true checkbox3.viseble:=true gibi sayı kadar kodu yazdırabildim. onu bir buttonclikinde nasıl kullanabilirim buda olabilir. Farklı bakış açılarınada açığım.
sayı kadar ekranda checkbox gözüksün.
Forum kuralları
Bu forum sadece yapacağınız işle alakalı doğru bileşeni bulmak içindir. Şöyle bir şey yapmam lazım, hangi bileşeni kullanıyım diyorsanız, doğru yerdesiniz.
Bu forum sadece yapacağınız işle alakalı doğru bileşeni bulmak içindir. Şöyle bir şey yapmam lazım, hangi bileşeni kullanıyım diyorsanız, doğru yerdesiniz.
Re: sayı kadar ekranda checkbox gözüksün.
FindComponent komutu ile bir bileşeni ismine göre bulabilirsin. Bileşeni bulduktan sonra istediğin özelliğini değiştirmek sana kalmış.
There's no place like 127.0.0.1
Re: sayı kadar ekranda checkbox gözüksün.
hocam biraz açabilirmisin,ingilizcem çok iyi değil benim ve hangi amaçla kullanılıyor bu komut ?
Re: sayı kadar ekranda checkbox gözüksün.
arkadaşlar netten buldum, benzer bir şekilde proje yapan arakdaş olabilir diye paylaşıyorum.
Kod: Tümünü seç
var
nesne: Integer;
begin
for nesne:=1 to 20 do
Tcheckbox(FindComponent('checkbox'+inttostr( nesne ))).visible:=true;
end;
Re: sayı kadar ekranda checkbox gözüksün.
Sanırım şöyle bir kod işini görür;
Şu ekran görüntüsü;

Bu da DFM dosyası
Şu ekran görüntüsü;
Kod: Tümünü seç
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
Panel1: TPanel;
LB_Miktar: TLabel;
ED_Miktar: TEdit;
BT_Olustur: TButton;
Memo1: TMemo;
Splitter1: TSplitter;
procedure GenelKlik(Sender: TObject);
procedure KeyPress_SadereRakam(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
function Olustur_CheckBox(aParent: TWinControl; aBaslik: String; aTag, X, Y: Integer): TCheckBox;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GenelKlik(Sender: TObject);
var
aCheckBox: TCheckBox;
I, Q: Integer;
aX, aY: Integer;
aName: String;
begin
if (Sender = BT_Olustur) then begin
Q := StrToInt(ED_Miktar.Text);
if not Q > 1 then exit;
aX := 10;
aY := 10;
for I := 1 to Q do begin
try
aCheckBox := Olustur_CheckBox(ScrollBox1, format('CheckBox_%d', [I]) , I, aX, aY);
except
end;
Inc(aX, 10);
Inc(aY, 20);
end;
end else
if Sender is TCheckBox then begin
aCheckBox := TCheckbox(Sender);
if aCheckBox.Checked
then Memo1.Lines.Add( format('%s = işaretli (%d)', [aCheckBox.Caption, aCheckBox.Tag]) )
else Memo1.Lines.Add( format('%s = boşta (%d)', [aCheckBox.Caption, aCheckBox.Tag]) ) ;
end;
end;
procedure TForm1.KeyPress_SadereRakam(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then Key := #0;
end;
function TForm1.Olustur_CheckBox(aParent: TWinControl; aBaslik: String; aTag, X, Y: Integer): TCheckBox;
var
aCheckBox: TComponent;
begin
Result := TCheckBox.Create(aParent);
with Result do begin
Name := format('CheckBox_%d', [aTag]);
Parent := aParent;
Caption := aBaslik;
Tag := aTag;
Top := Y;
Left := X;
OnClick := GenelKlik;
end;
end;
end.
Kod: Tümünü seç
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 265
ClientWidth = 516
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 350
Top = 29
Width = 6
Height = 236
Align = alRight
ResizeStyle = rsUpdate
ExplicitLeft = 0
end
object ScrollBox1: TScrollBox
Left = 0
Top = 29
Width = 350
Height = 236
Align = alClient
TabOrder = 0
ExplicitWidth = 356
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 516
Height = 29
Align = alTop
TabOrder = 1
object LB_Miktar: TLabel
AlignWithMargins = True
Left = 11
Top = 4
Width = 81
Height = 21
Margins.Left = 10
Margins.Right = 0
Align = alLeft
Caption = 'Checkbox Miktar'#305
Layout = tlCenter
ExplicitHeight = 13
end
object ED_Miktar: TEdit
AlignWithMargins = True
Left = 95
Top = 4
Width = 52
Height = 21
Align = alLeft
TabOrder = 0
Text = '10'
OnKeyPress = KeyPress_SadereRakam
end
object BT_Olustur: TButton
Left = 150
Top = 1
Width = 75
Height = 27
Align = alLeft
Caption = 'Olu'#351'tur'
TabOrder = 1
OnClick = GenelKlik
end
end
object Memo1: TMemo
Left = 356
Top = 29
Width = 160
Height = 236
Align = alRight
ScrollBars = ssVertical
TabOrder = 2
end
end
- ender_arslanturk
- Kıdemli Üye
- Mesajlar: 709
- Kayıt: 18 Şub 2005 03:38
- Konum: İstanbul
Re: sayı kadar ekranda checkbox gözüksün.
Ayrıca Raize bileşen setinin RzCheckTree sini de incelemelisiniz.