Srodne teme
Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

CheckBox-ovi u StringGrid-u?!

[es] :: Pascal / Delphi / Kylix :: CheckBox-ovi u StringGrid-u?!

[ Pregleda: 2081 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

spectra
BiH

Član broj: 34933
Poruke: 19
*.as58.ob.bih.net.ba.



Profil

icon CheckBox-ovi u StringGrid-u?!14.01.2005. u 01:32 - pre 207 meseci
Pozdrav svima,

...radim jedan programcic, ali sam naisla na problem, i evo me ovdje da vas zamolim da mi pomognete da ga rijesim...Evo, o cemu se radi:

Ubacujem podatke u StringGrid, s tim sto nije uvijek isti broj kolona i/ili redova (znaci nekada ima vise,a nekada manje podataka koji se ubacuju), i kako sada staviti CeheckBox-ove u prvu kolonu da se moze checkirati svaki red?

Molim vas, pomozite...
Carpe diem!
 
Odgovor na temu

bancika
Branislav Stojkovic

Član broj: 24844
Poruke: 631
213.244.197.*

Sajt: www.diy-fever.com


+1 Profil

icon Re: CheckBox-ovi u StringGrid-u?!14.01.2005. u 13:35 - pre 207 meseci
pogledaj na delphi3000.com ima clanak kako ubaciti comboBox-ove u stringGrid. ne bi trebalo da je mnogo drugacije. ako se zakocis negde reci
Ride the rainbow, crack the sky

DIY gitare, pojacala i efekti www.diy-fever.com
 
Odgovor na temu

spectra
BiH

Član broj: 34933
Poruke: 19
*.as58.ob.bih.net.ba.



Profil

icon Re: CheckBox-ovi u StringGrid-u?!15.01.2005. u 20:31 - pre 207 meseci
Hvala ti puno! Upravo to je ono sto trazim! :)
Carpe diem!
 
Odgovor na temu

spectra
BiH

Član broj: 34933
Poruke: 19
*.as58.ob.bih.net.ba.



Profil

icon Re: CheckBox-ovi u StringGrid-u?!16.01.2005. u 22:22 - pre 207 meseci
Evo, jos jedan primjer vezan za ovaj slucaj, pa neka se nadje ovdje ako jos nekome zatreba... :)

You can "emulate" checkboxes through:

1. Create new class thats represent cell value. // StringGrid have an Objects property
2. define eventhandler OnClick from StringGrid // calculate cell when user click
3. in CellObject class define draw method

.....

Simple Example:
// on Form only StringGrid1

type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
State: TGridDrawState);
procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

TCellObj = class
private
_grid : TStringGrid;
_value : boolean;
public
property Value : boolean read _value;

procedure ChangeValue;

procedure Draw(Rect: TRect; State: TGridDrawState);
constructor Create(grid : TStringGrid);
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if Assigned(StringGrid1.Objects[ACol, ARow]) then
(StringGrid1.Objects[ACol, ARow] as TCellObj).Draw(Rect, State);
end;

{ TCellObj }

constructor TCellObj.Create(grid: TStringGrid);
begin
_grid := grid;
_value := false;
end;

procedure TCellObj.Draw(Rect: TRect; State: TGridDrawState);
begin
try
if _value then
DrawFrameControl(_grid.Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK)
else
DrawFrameControl(_grid.Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_CHECKED);
except

end;
end;

procedure TCellObj.ChangeValue;
begin
_value := not _value;
end;

procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var ACol, ARow : integer;
begin
StringGrid1.MouseToCell(X, Y, ACol, ARow);

if Assigned(StringGrid1.Objects[ACol, ARow]) then
(StringGrid1.Objects[ACol, ARow] as TCellObj).ChangeValue;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: integer;
begin
StringGrid1.DefaultDrawing := false;
for i:=1 to StringGrid1.ColCount-1 do
for j := 1 to StringGrid1.RowCount - 1 do
StringGrid1.Objects[i, j] := TCellObj.Create(StringGrid1);
end;

end.

Carpe diem!
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: CheckBox-ovi u StringGrid-u?!

[ Pregleda: 2081 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Srodne teme
Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.