Knightonline Yeni Koxp %100 Bedava Video Oyun Program Film İndir - Ödev indir Resim Galerisi - Komik Youtube Video - Temalar - Oyun - Program İndir - Eylem - Msn Program - Resim Galerisi - Download - Aşk&Sevgi - Sohbet - Geyik - Eğlence - Komik Resimler - Videolar - Sanatçılar - Şarkı Sözleri - Online Oyunlar - Oyun indir - Film - Resim Arşivi

Tam Versiyon: Listbox'ta ve Table da arama (güzel bişey)
Şu anda tam olmayan bir versiyonun içeriğine bakıyorsunuz. Tam versiyona bakınız.
Listbox'ta ve Table da arama (güzel bişey)
Delphi6 daki Ctrl-F12 tuşuyla çağırdığım View Unit sekmesinde ki gibi bir çalışma ve bu özelliğin DBGrid üzerine uyarlanmış hali.. Umarım birilerinin işine yarar.
(Bu kodlar Raize Componenttinden yararlanarak yapılmıştır)/// masa üstüne listbox diye bi klasör oluşturun
/// Kutukdbf yapısı
/// SIRANO N10
/// SICIL C10
/// ADI C25
/// UNVAN C10
/// Index->ADI alanından ADISOYADI

unit son;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, Buttons, ExtCtrls, DBCtrls, Grids,
DBGrids;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
DataSource1: TDataSource;
Table1: TTable;
BitBtn1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Button3: TButton;
Button4: TButton;
DBGrid1: TDBGrid;
Edit2: TEdit;
DBNavigator1: TDBNavigator;
Table1SIRANO: TFloatField;
Table1SICIL: TStringField;
Table1ADI: TStringField;
Table1UNVAN: TStringField;
Bevel1: TBevel;
Bevel2: TBevel;
Label3: TLabel;
Label4: TLabel;
procedure Edit1Change(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ListBox1DblClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ListBox1KeyPress(Sender: TObject; var Key: Char);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
function FindClosest( S: string ): Integer;
public
SearchField: string; //Dbgrid için
KeyField: string; //Dbgrid için
NumbersOnly: Boolean; //Dbgrid için
procedure FindKeyField( const KeyValue: string ); //Dbgrid için
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function TForm1.FindClosest( S: string ): Integer;
begin
for Result := 0 to Listbox1.Items.Count - 1 do
if AnsiCompareText( Copy( Listbox1.Items[ Result ], 1, Length( S ) ), S ) = 0 then
Exit;
Result := -1;
end;

Function HARFBUYUT(Harf:Char):Char;
Begin
Case Harf of
'ı':Result:='I';
'ğ':Result:='Ğ';
'ü':Result:='Ü';
'ş':Result:='Ş';
'i':Result:='İ';
'ö':Result:='Ö';
'ç':Result:='Ç';
Else
Result:=UpCase(Harf);
End;
End;

procedure TForm1.Edit1Change(Sender: TObject);
var
I: Integer;
begin
I := FindClosest( Edit1.Text );
if I <> -1 then
Listbox1.ItemIndex := I;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
Edit1.Width := Listbox1.Width;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
Listbox1.Clear;
While Not Table1.Eof Do
Begin
Table1.Edit;
Listbox1.Items.Add(Table1ADI.AsString);
Table1.Next;
End;

Edit2.Width := DBGrid1.Width;
Edit2.Text:=";
Edit1.SetFocus;
Edit1.SelStart := Length( Edit1.Text );
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ( Key = vk_Down ) or ( Key = vk_Up ) then
begin
if Key = vk_Down then
begin
if Listbox1.ItemIndex < Listbox1.Count - 1 then
Begin
Listbox1.ItemIndex := Listbox1.ItemIndex + 1;
Edit1.Text:=ListBox1.Items[ListBox1.ItemIndex]
End
end
else
begin
if Listbox1.ItemIndex > 0 then
Begin
Listbox1.ItemIndex := Listbox1.ItemIndex - 1;
Edit1.Text:=ListBox1.Items[ListBox1.ItemIndex]
End;
end;
Key := 0;
end;
end;

procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
Button1.Click;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Showmessage(ListBox1.Items[ListBox1.ItemIndex]);
Edit1.Text:=";
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
Key:=HARFBUYUT(Key);
if key = #13 then
Button1.Click;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:=";
Edit1.SetFocus;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
Button1.Click;
end;

procedure TForm1.Button3Click(Sender: TObject);
var deger : string;
begin
deger:= InputBox('Lütfen bir isim girin', ", ");
If length(deger)>0 Then
ListBox1.Items.Add(deger);
Edit1.SetFocus
end;

procedure TForm1.Button4Click(Sender: TObject);
var deger : string;
begin
deger:=ListBox1.Items[ListBox1.ItemIndex]+' isimli kişi silinecek'+#13+'(İsterseniz burada kayıtta sildirebilirsiniz)';
if Application.MessageBox(pchar(deger), 'Listbox tan kayıt sil',
MB_OKCANCEL + MB_DEFBUTTON2) = IDOK then
Listbox1.DeleteSelected;
Edit1.SetFocus
end;
// Listbox1 sonu
procedure TForm1.FindKeyField( const KeyValue: string );
begin
DataSource1.Dataset.DisableControls;
try
if KeyValue = " then
DataSource1.Dataset.First
else
DataSource1.Dataset.Locate( KeyField, KeyValue, [ loPartialKey, loCaseInsensitive ] );
Edit2.Text := DataSource1.Dataset.FieldByName( SearchField ).AsString;
finally
DataSource1.Dataset.EnableControls;
end;
end;

procedure TForm1.Edit2Change(Sender: TObject);
var
S: string;
begin
DataSource1.Dataset.DisableControls;
try
if Edit2.Text = " then
DataSource1.Dataset.First
else
begin
S := QuotedStr( Edit2.Text );
S := Copy( S, 2, Length( S ) - 2 );
DataSource1.Dataset.Locate( 'ADI', S, [ loPartialKey, loCaseInsensitive ] );
end;
finally
DataSource1.Dataset.EnableControls;
end;
end;

procedure TForm1.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ( Key = vk_Down ) or ( Key = vk_Up ) then
begin
if Key = vk_Down then
Begin
DataSource1.Dataset.Next;
Edit2.Text:=Table1ADI.AsString;
End
else
Begin
DataSource1.Dataset.Prior;
Edit2.Text:=Table1ADI.AsString;
End;
Key := 0;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
Key:=HARFBUYUT(Key);
if NumbersOnly and
( Key in [ #32..#255 ] ) and
not ( Key in [ '-', '+', '0'..'9' ] ) then
begin
MessageBeep( 0 );
Key := #0;
end;
end;

end.
////////// dpr'si
object Form1: TForm1
Left = 22
Top = 194
BorderStyle = bsDialog
Caption = 'Listbox yöntemlerinden bazıları'
ClientHeight = 349
ClientWidth = 855
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnResize = FormResize
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 432
Top = 312
Width = 349
Height = 13
Caption =
'Türkçe karekter destekli Listboxta arama yönemi umarın birilerin' +
'i işine yarar'
end
object Label2: TLabel
Left = 435
Top = 326
Width = 287
Height = 13
Caption = 'MbzSoft Tokat (Mehmet BOZKURT mbz060@yahoo.com )'
end
object Bevel1: TBevel
Left = 3
Top = 8
Width = 417
Height = 281
Shape = bsFrame
end
object Bevel2: TBevel
Left = 427
Top = 8
Width = 417
Height = 281
Shape = bsFrame
end
object Label3: TLabel
Left = 8
Top = 304
Width = 329
Height = 13
Caption = 'Not : Ekle ve sil butonu sadece Listboz üzerinde etkilidir. '
FocusControl = BitBtn1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
end
object Label4: TLabel
Left = 40
Top = 320
Width = 211
Height = 13
Caption = 'Kutuk.dbf dosyasına müdahele etmez'
FocusControl = BitBtn1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
end
object ListBox1: TListBox
Left = 15
Top = 40
Width = 297
Height = 241
Style = lbOwnerDrawFixed
ItemHeight = 16
Sorted = True
TabOrder = 0
OnDblClick = ListBox1DblClick
OnKeyPress = ListBox1KeyPress
end
object Edit1: TEdit
Left = 15
Top = 16
Width = 297
Height = 21
TabOrder = 1
OnChange = Edit1Change
OnKeyDown = Edit1KeyDown
OnKeyPress = Edit1KeyPress
end
object Button1: TButton
Left = 327
Top = 24
Width = 75
Height = 25
Caption = 'Tamam'
ModalResult = 1
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 327
Top = 56
Width = 75
Height = 25
Caption = 'Temizle'
TabOrder = 3
OnClick = Button2Click
end
object BitBtn1: TBitBtn
Left = 335
Top = 256
Width = 65
Height = 25
Caption = 'Çık'
TabOrder = 4
OnClick = BitBtn1Click
Glyph.Data = {
76010000424D76010000000000007600000028000000200000 00100000000100
04000000000000010000120B0000120B000010000000000000 00000000000000
800000800000008080008000000080008000808000007F7F7F 00BFBFBF000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF 00330000000000
03333377777777777F333301BBBBBBBB033333773F3333337F 3333011BBBBBBB
0333337F73F333337F33330111BBBBBB0333337F373F33337F 333301110BBBBB
0333337F337F33337F333301110BBBBB0333337F337F33337F 333301110BBBBB
0333337F337F33337F333301110BBBBB0333337F337F33337F 333301110BBBBB
0333337F337F33337F333301110BBBBB0333337F337FF3337F 33330111B0BBBB
0333337F337733337F333301110BBBBB0333337F337F33337F 333301110BBBBB
0333337F3F7F33337F333301E10BBBBB0333337F7F7F33337F 333301EE0BBBBB
0333337F777FFFFF7F33330000000000033333777777777773 33}
NumGlyphs = 2
end
object Button3: TButton
Left = 327
Top = 112
Width = 75
Height = 25
Caption = 'Ekle'
TabOrder = 5
OnClick = Button3Click
end
object Button4: TButton
Left = 327
Top = 144
Width = 75
Height = 25
Caption = 'Sil'
TabOrder = 6
OnClick = Button4Click
end
object DBGrid1: TDBGrid
Left = 439
Top = 72
Width = 385
Height = 209
DataSource = DataSource1
TabOrder = 7
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'ADI'
Title.Caption = 'Adı Soyadı'
Width = 170
Visible = True
end
item
Expanded = False
FieldName = 'UNVAN'
Title.Caption = 'Ünvanı'
Width = 106
Visible = True
end
item
Expanded = False
FieldName = 'SICIL'
Title.Caption = 'Sicil No'
Visible = True
end>
end
object Edit2: TEdit
Left = 439
Top = 16
Width = 297
Height = 21
TabOrder = 8
Text = 'Edit2'
OnChange = Edit2Change
OnKeyDown = Edit2KeyDown
OnKeyPress = Edit2KeyPress
end
object DBNavigator1: TDBNavigator
Left = 439
Top = 40
Width = 136
Height = 25
DataSource = DataSource1
VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast]
TabOrder = 9
end
object DataSource1: TDataSource
DataSet = Table1
Left = 320
Top = 200
end
object Table1: TTable
Active = True
DatabaseName =
'C:\********s and Settings\Mehmet_Bozkurt\Desktop\listbox' +
'işey'
IndexFieldNames = 'ADI'
TableName = 'Kutuk.DBF'
Left = 320
Top = 224
object Table1SIRANO: TFloatField
FieldName = 'SIRANO'
end
object Table1SICIL: TStringField
FieldName = 'SICIL'
Size = 10
end
object Table1ADI: TStringField
FieldName = 'ADI'
Size = 25
end
object Table1UNVAN: TStringField
FieldName = 'UNVAN'
Size = 10
end
end
end
Referans URL