ubah value di TDBGrid

Pemrograman Delphi

ubah value di TDBGrid

Postby kylix » 29 Apr 2011, 16:32

selamat sore...
mo nanya nih, :)

gmana ya caranya ngubah value di DBGrid,
jadi saya punya table user,
ada field username(string) dan status (integer),
nah, saya mo nampilin field status di DBGrid dengan value yang berbeda(dgn format string),
misal : 0 = 'admin' , 1 = 'member'

oya, untuk koneksinya saya gunain adoquery, datasource dan DBGrid untuk nampilin.


makasih.. :biggrin:
kylix
Junior Member
 
Posts: 7
Joined: 14 Feb 2011, 15:20

RE: ubah value di TDBGrid

Postby D.E » 29 Apr 2011, 16:39

Gunakan Calculate field aja (virtual field):
1. Di ADOQuery fields editor: Add new (virtual) field, set type = Calculated field
2. ADOQuery.OnCalculateField:
if TDateSet(Sender).FieldByName('TypeMemberField').AsInteger = 0 then
ADOQueryXCalcFieldName.Value := 'Admin'
else ... Value := 'Member';

3. Di DBGrid buang field asli, ganti dng calc field tadi

Kira2 begitulah langkah2nya, sesuaikan saya udah agak2 lupa :)
:idea: Dude, if you don't understand the basics and just want to get someone else write the code for you, it means you really shouldn't study computer science. Find different field!
User avatar
D.E
Senior Member
 
Posts: 638
Joined: 04 May 2010, 18:12

RE: ubah value di TDBGrid

Postby mambamaestro » 02 May 2011, 12:40

ham hem... bisa jalan gak yach? :D
mambamaestro
Member
 
Posts: 156
Joined: 06 May 2010, 14:14
Location: Surabaya


Who is online

Users browsing this forum: No registered users and 2 guests

cron