Yazdığınız makaleleri ve üyelerimizin işine yarayacağını düşündüğünüz kodlarınızı gönderebilirsiniz. Bu foruma soru sormayın!
abdulkadir
Kıdemli Üye
Mesajlar: 489 Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:
Mesaj
gönderen abdulkadir » 12 May 2009 05:00
S.a
items haricinde value özelligi olan bir combobox a ihtiyacınız varsa buyrun
Kod: Tümünü seç
{************************************************************}
{ CodeGear Delphi 2007 Visual Component Library den }
{ TComboBox Sınıfından olusuturulmuş }
{ Ek olarak }
{ Values ve About özelligi eklenmistir }
{ Abdulkadir LEVENT 12.05.2009 }
{************************************************************}
unit MyComboBox;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
type
TMyComboBox = class(TComboBox)
private
{ Private declarations }
FAbout: String;
FValues: TStrings;
procedure SetValues(Value: TStrings);
function Get_About: string;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Values: TStrings read FValues write SetValues;
property About: string read Get_About write FAbout stored False;
end;
procedure Register;
implementation
constructor TMyComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FValues := TStringList.Create;
Style := csDropDownList;
end;
destructor TMyComboBox.Destroy;
begin
TStringList(FValues).OnChange := nil;
FValues.Free;
inherited Destroy;
end;
procedure TMyComboBox.SetValues(Value: TStrings);
begin
FValues.Assign(Value);
end;
function TMyComboBox.Get_About: string;
begin
Result :='Abdulkadir LEVENT';
end;
procedure Register;
begin
//hangi component baslıgı altına kaydedilsin (Tool Palette)
RegisterComponents('Abdulkadir', [TMyComboBox]);
end;
end.
Bunu delphide nasıl derleyeceginizi bilirsiniz herhalde anlatmaya gerek duymuyorum
forumda bu konu fazlası ile mevcuttur.
iyi calısmalar
abdulkadir
Kıdemli Üye
Mesajlar: 489 Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:
Mesaj
gönderen abdulkadir » 12 May 2009 05:10
Kullanıma örnek yazmadan gecmeyeyim
//MyComboBox componenti yuklenmiş olmalı
Kod: Tümünü seç
//form create edilirken MyComboBox1 items ve value degerlerini yukleyelim.
procedure TForm3.FormCreate(Sender: TObject);
begin
MyComboBox1.Items.Clear;//gecmisi sil
MyComboBox1.Values.Clear;
MyComboBox1.Items.Add('Abdulkadir');MyComboBox1.Values.Add('1999');
MyComboBox1.Items.Add('Ahmet'); MyComboBox1.Values.Add('2006');
MyComboBox1.Items.Add('Mustafa'); MyComboBox1.Values.Add('1516');
MyComboBox1.Items.Add('Hüseyin'); MyComboBox1.Values.Add('2345');
MyComboBox1.Items.Add('Kemal'); MyComboBox1.Values.Add('677809');
MyComboBox1.Items.Add('Cemal'); MyComboBox1.Values.Add('776543');
MyComboBox1.Items.Add('Yahya'); MyComboBox1.Values.Add('0987654');
MyComboBox1.Items.Add('Bulut'); MyComboBox1.Values.Add('0987654');
end;
MyComboBox1 onClick olayına asagıdaki kodu yazalım
Kod: Tümünü seç
procedure TForm3.MyComboBox1Click(Sender: TObject);
var Item,Value:String;
begin
if MyComboBox1.ItemIndex > -1 then begin
Item:=MyComboBox1.Items[MyComboBox1.ItemIndex];
Value:=MyComboBox1.Values[MyComboBox1.ItemIndex];
ShowMessage('Seçilen Satır:= '+Item +' Value:= '+Value );
end;
end;
bu satırları yazarken bunu yaptın bari paketi derle bilmeyenler ugrasmasın diye hep gecti içimden
ve derledim zipli dosya linki asagıda
http://rapidshare.com/files/232105402/A ... T.zip.html
Sevgiler....
Battosai
Üye
Mesajlar: 1316 Kayıt: 01 Eki 2007 12:02
Konum: Ankara
Mesaj
gönderen Battosai » 12 May 2009 05:50
Aslında MyComboBox1.Items.AddX('Abdulkadir','2006'); şeklinde ekleme yapılabilen bir özellik eklerseniz daha şık olurdu bu MyCombobox...
abdulkadir
Kıdemli Üye
Mesajlar: 489 Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:
Mesaj
gönderen abdulkadir » 13 May 2009 02:59
Battosai yazdı: Aslında MyComboBox1.Items.AddX('Abdulkadir','2006'); şeklinde ekleme yapılabilen bir özellik eklerseniz daha şık olurdu bu MyCombobox...
Sende haklısın
geliştirmeye yönelik çok seyler yapılabilir.
bence ihtiyacı karsılıyorsa en basitve anlasılır sekilde kullanmak daha verimlidir.
Zaman bulursam eklerim inş.
Battosai
Üye
Mesajlar: 1316 Kayıt: 01 Eki 2007 12:02
Konum: Ankara
Mesaj
gönderen Battosai » 13 May 2009 03:17
Biraz da bizim katkımız olsun dedim ve bir kaç özellik ekleyip düzenledim unit'i...
Kod: Tümünü seç
unit ValueComboBox;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
type
TValComboBox = class(TComboBox)
private
{ Private declarations }
FValues: TStrings;
procedure SetValues(Value: TStrings);
protected
{ Protected declarations }
public
{ Public declarations }
procedure AddX(Caption,Value:string);
procedure ClearX;
function GetSelectedValue:string;
procedure SavetoFileEx(const FileName:string);
procedure LoadFromFileEx(const FileName:string);
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Values: TStrings read FValues write SetValues;
end;
procedure Register;
implementation
procedure TValComboBox.AddX(Caption, Value: string);
begin
Items.Add(Caption);
Values.Add(Value);
end;
procedure TValComboBox.ClearX;
begin
items.Clear;
Values.Clear;
end;
constructor TValComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FValues := TStringList.Create;
Style := csDropDownList;
end;
destructor TValComboBox.Destroy;
begin
TStringList(FValues).OnChange := nil;
FValues.Free;
inherited Destroy;
end;
function TValComboBox.GetSelectedValue: string;
begin
Result:='';
if ItemIndex>-1 then
Result:=Values.Strings[itemindex];
end;
procedure TValComboBox.LoadFromFileEx(const FileName:string);
var
Slist:TStringList;
S,Caption,Value:string;
i:integer;
begin
try
items.Clear;
Values.Clear;
Slist:=TStringList.Create;
Slist.LoadFromFile(FileName);
if Slist.Text<>'' then
Begin
for i:= 0 to Slist.Count-1 do
Begin
S:=Slist.Strings[i];
Caption:=copy(S,1,pos(':=',S)-1);
Value:=copy(S,Pos(':=',S)+2,length(S));
Items.Add(Caption);
Values.Add(Value);
End;
End;
Finally
FreeAndNil(Slist);
End;
end;
procedure TValComboBox.SavetoFileEx(const FileName:string);
var
slist:TStringList;
i,count:integer;
begin
try
slist:=TStringList.Create;
count:=items.Count;
if items.Count>Values.Count then
Begin
count:=Values.Count;
End;
for i :=0 to Count-1 do
Begin
slist.Add(Items.Strings[i]+':='+Values.Strings[i]);
End;
slist.SaveToFile(FileName);
Finally
FreeAndNil(slist);
End;
end;
procedure TValComboBox.SetValues(Value: TStrings);
begin
FValues.Assign(Value);
end;
procedure Register;
begin
RegisterComponents('Samples', [TValComboBox]);
end;
end.
Yeni eklenenler özellikler;
Kod: Tümünü seç
ValCombobox.AddX('Ankara','06'); // yeni kayıt girdik Ankara değerine value olarak 06 atadık...
ValCombobox.clearX; // items ve values birlikte temizler...bu bileşen için clear yerine kullanılması uygundur..
ValCombobox.SavetoFileEx('C:\test.txt'); // başlık ve değeri yan yana kayıt eder....örn Ankara:=06 şeklinde...
ValCombobox.LoadFromFileEx('C:\test.txt');// Ankara:=06 olarak kayıt edilen içeriği items ve values değerleri şeklinde yükler...
ValCombobox.GetSelectedValue; // Seçili kayıtın value değerine döndürür...
abdulkadir
Kıdemli Üye
Mesajlar: 489 Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:
Mesaj
gönderen abdulkadir » 13 May 2009 05:51
Ellerine saglık
dahada gelistirmek için bir sınır yoktur.
herkes ihtiyacını ekler ve kullanır.
sevgiler...