![]() |
|
DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Genel Programlama (https://www.delphican.com/forumdisplay.php?fid=6) +--- Konu Başlığı: DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. (/showthread.php?tid=8093) |
DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - OZCANK - 22-03-2025 Arkadaşlar Merhaba; Bir sorunum var ve sizlerden yardım istiyorum. Delphi7 Kullanıyorum. Form1 de DBGrid1 var ve Alanlarını isteğe göre gizleyip göstermek istiyorum. Cari Kod = CARI_KOD Cari Isim = CARI_ISIM Stok Kodu = STOK_KODU .. .. .. Şeklinde PopupMenu Ekledim ve bu alanları da tanımladım. DBGrid1 de sağ klik yapınca Cari Kod a tıkladığımda gizlenmesini tekrar tıkladığım da görünmesini sağlamak istiyorum. PopupMenu de Checked özeliği var görünüyorsa işaretli aksi durumda işaretsiz ayarlamaya uğraştım olmadı. Yardımcı olursanız veya fikir verirseniz çok sevinirim. procedure TForm16.CariKod1Click(Sender: TObject); var i: Integer; ColumnIndex: Integer; begin // CariKod1'in Checked durumunu tersine çevir CariKod1.Checked := not CariKod1.Checked; // CARI_KOD sütununu bul ColumnIndex := 0; for i := 0 to DBGrid1.Columns.Count - 0 do begin if DBGrid1.Columns[0].FieldName = 'CARI_KOD' then begin ColumnIndex := i; Break; end; end; // Sütun bulunduysa, Checked durumuna göre gizle veya göster if ColumnIndex = 0 then begin if CariKod1.Checked then DBGrid1.Columns[ColumnIndex].Visible := False // CariKod1 işaretliyse sütunu gizle else DBGrid1.Columns[ColumnIndex].Visible := True; // CariKod1 işaretli değilse sütunu göster end; end; Bu şekilde bir kod yapısı var ama istediğim gibi olmadı. işaretliyorum gizliyor sonra DBGrid e dönünce tekrar görünüyor anlamadım. DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - frmman - 22-03-2025 Tam olarak istediğiniz şeymi bilemiyorum ama paylaştığınız kod aşağıdaki şekilde düzenlendiğinde daha sorunsuz hale gelecektir. ![]() procedure TForm16.CariKod1Click(Sender: TObject); var i: Integer; begin // CariKod1'in Checked durumunu tersine çevir CariKod1.Checked := not CariKod1.Checked; // CARI_KOD sütununu bul for i := 0 to DBGrid1.Columns.Count - 1 do begin if DBGrid1.Columns[i].FieldName = 'CARI_KOD' then begin if CariKod1.Checked then DBGrid1.Columns[i].Visible := False // CariKod1 işaretliyse sütunu gizle else DBGrid1.Columns[i].Visible := True; // CariKod1 işaretli değilse sütunu göster Break; end; end; end; DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - OZCANK - 22-03-2025 Çok teşekkür ederim. Emeğine sağlık. Son birşey ben bu alanları c:\ sürücüsün de AYARLAR.INI dosyasına [Columns] CARI_KOD=0 CARI_ISIM=1 PLASIYER_KODU=1 Şeklinde kaydediyorum. Sağ Klik yaptığım da 0 ve 1 e göre Cari Kod un durumunu verebilir miyim ? İşaretli veya İşaretsiz şeklinde. DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - frmman - 23-03-2025 Mevcut yapınıza göre aşağıdaki şekilde bir yaklaşım ile istediğinizi yapabilirsiniz. FormCreate de ini dosyasını okuma işlemleini yaptıkdan sonra aşağıdaki şekilde bir yaklaşımla istediğiniz sonuca ulaşabilirsiniz. // form create de yapılacak işlemler // ini dosyasından okuma işlemleri // ini dosyasında CARI_KOD değişken değeri kontrol edilir. // CariKod1.OnClick eventinde aşağıdaki şekilde NOT (değili) alındığı için // CariKod1.Checked := not CariKod1.Checked; // CARI_KOD = 0 ini değeri için CariKod1.checked := true değeri gönderiliyor. if CARI_KOD = 0 then CariKod1.checked := True else CariKod1Checked := False; CariKod1.OnClick(sender); //.... diğer işlemler Cvp: DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. - metemet - 05-04-2025 unit my_compenent;
interface
uses
SysUtils, Classes, Controls, StdCtrls,ComCtrls,Mask, DBCtrls, Buttons,Grids, DBGrids,
Windows, Messages, Graphics;
type
TDBGrid_Button = class(TDBGrid)
private
{ Private declarations }
FRowHeight : Integer ;
Protected
Procedure
SetRowHeight(Value:Integer);
protected
{ Protected declarations }
public
Function CellRect(ACol,Arow : Longint):TRect; Reintroduce;
Property Row ;
Property Col ;
{ Public declarations }
published
{ Published declarations }
Property RowHeight : Integer
Read FRowHeight Write SetRowHeight ;
property OnMouseWheel;
end;
procedure Register;
implementation
Function TDBGrid_Button.CellRect(ACol,ARow:Longint):TRect;
Begin
Result := Inherited CellRect(ACol, ARow);
End;
Procedure TDBGrid_Button.SetRowHeight(Value:Integer);
Begin
If FRowHeight <> Value Then Begin
FRowHeight := Value ;
DefaultRowHeight := FRowHeight ;
If Self.DataLink.Active Then Begin
Perform(WM_SIZE,0,0);
End;
End;
End;
procedure Register;
begin
RegisterComponents('Data Controls', [TDBGrid_Button]);
end;
end.
kullanımı bir tane checkBox: ekle aling atama none olacak SpeedButton_Sil_1 checkBox ismini yaz kolon genişliklerini ayarla procedure TKasa1_form.DBGrid_kasa1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Var DataRect : TRect ; Begin /// sil buton GÖSTERME SpeedButton_sil_1.Visible:=true; If (Column.Index = 4) Then Begin With DBGrid_kasa1 Do Begin DataRect := CellRect(Column.Index,Row); End; If SpeedButton_Sil_1.Parent <> DBGrid_kasa1 Then /// nesle hangi neslenin konrolunde SpeedButton_sil_1.Parent := DBGrid_kasa1 ; If (Column.Index = 4)then /// buraya kacıncı sutunda göterilecek If SpeedButton_Sil_1.Left <> (DataRect.Right + Column.Width) Then SpeedButton_sil_1.Left := (DataRect.Right + Column.Width) ; If (SpeedButton_sil_1.Top <> DataRect.Top) Then SpeedButton_sil_1.Top := DataRect.Top ; If (SpeedButton_sil_1.Height <> (DataRect.Bottom-DataRect.Top)) Then SpeedButton_sil_1.Height := (DataRect.Bottom-DataRect.Top); End; end; |