Arsip: re active control

 
user image
more 15 years ago

nurez

hii all posting ini dh pnah Sy post , tp pas sy coba2 lgg membuat aplikasi lagi, dgn melihat code2 di posting yg sblumnya, dgn urutan tab order yg benar. namun masih aja kursor tdk turun kebawah apabila di enter.. dan kursor terarah ke tomobl save yg tab ordernya "8"...... :( sc nya:

procedure Tformkaryawan.nipKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 case Key of
    VK_UP     : if not(Sender Is TComboBox) then 
                  SelectNext(Sender As TWinControl, False, True); 
    VK_DOWN   : if not(Sender Is TComboBox) then 
                  SelectNext(Sender As TWinControl, True, True); 
    VK_RETURN : SelectNext(Sender As TWinControl, True, True); 
  end ;
end;
end.
phan sy buat 1 aplikasi, trnyata bisa, mungkin krna code2nya ga trlalu rumit.. masa siY brpngaruh...? THx ats smua jawabannya .
user image
more 15 years ago

fafenail

Klo hanya sebetas Tab order dan Enter bisa diatasi dengan :

procedure TForm1.FormCreate(Sender: TObject);
begin
  KeyPreview:=True;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key =#13 then
  begin
    Key :=#0;
    Perform(CM_DialogKey, VK_Tab, 0);
  end;
end;
user image
more 15 years ago

nurez

wah masih ngga bisa jugha :( pdhal Sc lengkap nya :
unit pegawai;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ADODB, DB, Grids, DBGrids;
type
  Tformkaryawan = class(TForm)
    nip: TEdit;
    nama: TEdit;
    jab: TEdit;
    alamat: TEdit;
    jenis: TComboBox;
    mulai: TEdit;
    status: TComboBox;
    gol: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    GroupBox1: TGroupBox;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Query1: TADOQuery;
    pencarian: TGroupBox;
    save1: TBitBtn;
    edit1: TBitBtn;
    delete1: TBitBtn;
    clear1: TBitBtn;
    close1: TBitBtn;
    find1: TBitBtn;
    find2: TEdit;
    procedure save1Click(Sender: TObject);
    procedure find1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure edit1Click(Sender: TObject);
    procedure clear1Click(Sender: TObject);
    procedure delete1Click(Sender: TObject);
    procedure nipExit(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  formkaryawan: Tformkaryawan;

implementation

{$R *.dfm}
procedure Tformkaryawan.FormCreate(Sender: TObject);
begin
KeyPreview:=True;
nip.Text:='';
nama.Text:='';
status.Text:='';
alamat.Text:='';
jenis.Text:='';
gol.Text:='';
jab.Text:='';
mulai.Text:='';
status.Items.clear;
status.Items.append('menikah');
status.Items.append('single');
status.Items.append('janda');
status.Items.append('duda');
jenis.Items.clear;
jenis.Items.append('laki-laki');
jenis.Items.append('perempuan');
gol.Items.clear;
gol.Items.append('A1-Tetap');
gol.Items.append('A2-Bulanan');
gol.Items.append('A3-Harian');
edit1.enabled:=false;
delete1.enabled:=false;
end;
procedure Tformkaryawan.save1Click(Sender: TObject);
begin
  adotable1.Close;
  adotable1.Open;
  if adotable1.FieldValues['nip'] <> nip.Text  then
  begin
    adotable1.Append;
    adotable1.FieldValues['nip']:=nip.Text;
    adotable1.FieldValues['nama']:=nama.Text;
    adotable1.FieldValues['status']:=STATUS.Text;
    adotable1.FieldValues['alamat']:=alamat.Text;
    adotable1.FieldValues['JENIS']:=jenis.Text;
    adotable1.FieldValues['golongan']:=gol.Text;
    adotable1.FieldValues['jabatan']:=jab.Text;
    adotable1.FieldValues['mulai_kerja']:=mulai.Text;
    formcreate(sender);
    adotable1.UpdateRecord;
    adotable1.Post;
    showmessage('silakan dilihat di DBmsnya Udah Terupdate belum..?');
  end
  else
    showmessage('nip yang anda input sudah ada');
    nip.SetFocus;
end;
procedure Tformkaryawan.find1Click(Sender: TObject);
begin
if adotable1.Locate('nip',find2.Text,[loCaseInsensitive]) then
begin
  nip.Text:=adotable1.FieldValues['nip'];
  nama.Text:=adotable1.FieldValues['nama'];
  status.Text:=adotable1.FieldValues['status'];
  alamat.Text:=adotable1.FieldValues['alamat'];
  jenis.Text:=adotable1.FieldValues['jenis'];
  gol.Text:=adotable1.FieldValues['golongan'];
  jab.Text:=adotable1.FieldValues['jabatan'];
  mulai.Text:=adotable1.FieldValues['mulai_kerja'];
  find2.Text:='';
  save1.enabled:=false;
  edit1.enabled:=true;
  delete1.enabled:=true;
  end
  else
  showmessage('nip yang anda input tidak ada');
  find2.Text:='';
end;

procedure Tformkaryawan.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
pt: TGridcoord;
begin
pt:= DBGrid1.MouseCoord( x, y ) ;
//change the cursor when over title
if pt.y=0 then 
DBGrid1.Cursor:=crHandPoint
else 
DBGrid1.Cursor:=crDefault;
If pt.X > 0 Then 
Caption := Format( 'by= nurezio kolom: %d, baris: %d, field name: %s',
[pt.x, pt.y, DBGrid1.columns[pt.x-1].title.caption] )
Else
Caption := Format( 'kolom: %d, baris: %d',[pt.x, pt.y] ) ;
end;


procedure Tformkaryawan.edit1Click(Sender: TObject);
begin
adotable1.Edit;
adotable1.FieldValues['nip']:=nip.Text;
adotable1.FieldValues['nama']:=nama.Text;
adotable1.FieldValues['status']:=STATUS.Text;
adotable1.FieldValues['alamat']:=alamat.Text;
adotable1.FieldValues['JENIS']:=jenis.Text;
adotable1.FieldValues['golongan']:=gol.Text;
adotable1.FieldValues['jabatan']:=jab.Text;
adotable1.FieldValues['mulai_kerja']:=mulai.Text;
adotable1.post;
end;
procedure Tformkaryawan.clear1Click(Sender: TObject);
begin
formcreate(sender);
save1.enabled:=true;
nip.setfocus;
end;
procedure Tformkaryawan.delete1Click(Sender: TObject);
begin
adotable1.delete;
formcreate(sender);
save1.enabled:=true;
end;
procedure Tformkaryawan.nipExit(Sender: TObject);
begin
if adotable1.Locate('nip', nip.Text,[loCaseInsensitive])then
begin
  nip.Text:=adotable1.FieldValues['nip'];
  nama.Text:=adotable1.FieldValues['nama'];
  status.Text:=adotable1.FieldValues['status'];
  alamat.Text:=adotable1.FieldValues['alamat'];
  jenis.Text:=adotable1.FieldValues['jenis'];
  gol.Text:=adotable1.FieldValues['golongan'];
  jab.Text:=adotable1.FieldValues['jabatan'];
  mulai.Text:=adotable1.FieldValues['mulai_kerja'];
  showmessage('Data Udah Ada oiiii');
  clear1Click(sender);
end;
end;
procedure Tformkaryawan.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key =#13 then
  begin
    Key :=#0;
    Perform(CM_DialogKey, VK_Tab, 0);
  end;
end;
end.
dgn tab order yg berurutan 0-s/d 15 dgn keypreview=true pada formcreate... :(
user image
more 15 years ago

nurez

ya sy ajha d yg jawab :) hueheuheu dh nanya en jawab sndiri d :) mungkin bagi temen2 yg active controlnya nga brfungsi.? lbih baik di enabled:=false; ajha stiap yg tombol tab order nya "0" atau aktif sendiri, dn skiranya mo diaktifin.. buat ajha enablednya jadi true pd tombol yg akan dituju, ya gitorolis ajha d :) thx all dh jawab smua masalah ku ini :) aminnnnn
user image
more 15 years ago

deLogic

Agar suatu control dapat menerima focus ketika tombol tab ditekan, maka pastikan terlebih dahulu properti TabStop nya bernilai True. Jika nilainya true, maka akan menerima focus dengan urutan sesuai dnegan tab order, jika false, maka tidak dapat menerima focus.
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com