Autor Beitrag
bwolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50



BeitragVerfasst: Mi 29.03.06 14:57 
Hi all,

ich hab folgendes Problem, das mich seit längerem beschäftigt:

Ich hab ein DBGrid, in dem werden die Felder
vorname | nachname | anzahlessen | abgerechnet
aus einer DB angezeigt.

Jetzt versuche ich folgendes zu machen:
In den Reihen, wo abgerechnet 'true' ist, soll es nicht mehr möglich sein den Wert im Feld "anzahlessen" zu ändern.

Ich weiß das ich in der OnDrawColumnCell-Methode die einzelnen Columns beeinflussen kann - ich schaffs auch z.B meine 'abgerechneten' Felder rot einzufärben - aber ich schnall nicht wie ich den Column 'anzahlessen' auf readOnly krieg...

Kann mir jemand Tip geben ?
Vielen Dank schonmal für eure Hilfe,
gruß ben

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
 if Column.Field.DataType = ftBoolean then
 begin
  if Column.Field.AsString = 'True' then
    showmessage('Wie krieg ich das Column anzahlessen dieses Datensatzes auf readyonly ?');
 end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
bwolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50



BeitragVerfasst: Mi 29.03.06 19:54 
Hi,

nach langem rumgesuche bin ich dann endlich doch fündig geworden...endlich ^^

Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 if Column.Field.DataType = ftBoolean then
 begin
  if Column.Field.text = 'True' then
  begin
   DBGrid1.Columns[0].field.ReadOnly := true;
  end;
 end;

grüße,
ben

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Do 30.03.06 07:56 
Oder einfacher: Doppelklick auf die Table-Komponente, Rechtsklick "Alle Felder hinzufügen", dann gewünschtes Feld markieren und über den Objektinspektor ändern ;-)

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 30.03.06 08:00 
Nein, bloß nicht. Ich hasse persistente Felder. Die machen doch nur Probleme.
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Do 30.03.06 08:07 
Hehe. Und hier ist er wieder: Der Krieg zwischen RAD und sauberer Programmierung ;-)

Hat beides Vor- und Nachteile, stimmt.

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
bwolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50



BeitragVerfasst: Do 30.03.06 08:34 
Hi Leute,

hab mich gestern abend wohl zu früh gefreut.

Der Code setzt leider die komplette Spalte auf ReadOnly, und nicht nur das Feld.

Kann mir jemand verraten wie man sich auf das aktuelle Feld beziehen kann ?
Habs mit

ausblenden Quelltext
1:
SMDBGrid1.Columns[3].Field.ReadOnly := true;					


probiert, geht aber leider nicht.
Lustigerweise kann ich aber mit
ausblenden Quelltext
1:
SMDBGrid1.Columns[3].Field.Text := '9999';					


Den Wert von genau dem Feld beeinflusse, das eigentlich readOnly gesetzt werden soll.

Hoffe ihr habt noch einen Tip für mich,
grüße ben
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 30.03.06 08:45 
ich hatte das problem auch schon mal...
bin mir nicht sicher, aber ich glaub, ich habs damals über das OnSelectCell-Ereignis gemacht und dann einfach den Focus wo anders hingepackt... weiß es leider nicht mehr genau, hab das Prog auch nicht mehr, aber irgendwie wars möglich ;)
Hoffe, das hilft dir...
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 30.03.06 08:46 
Ganz kurz :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
 if Column.Field.DataType = ftBoolean then
 begin
   DBGrid1.Columns[0].field.ReadOnly := (Column.Field.text = 'True');
 end;


//EDIT: Aber das natürlich in OnSelectCell
bwolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50



BeitragVerfasst: Do 30.03.06 09:33 
Hoho!

Danke für die Antwort ! Geht jetzt endlich ;)


Ich hab das ganze jetzt im OnCellClick:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 if SMDBGrid1.Columns[5].Field.DataType = ftBoolean then
 begin
   if SMDBGrid1.Columns[5].Field.Text = 'True' then
    SMDBGrid1.Columns[3].field.ReadOnly := true
   else
    SMDBGrid1.Columns[3].field.ReadOnly := false;
 end;


Vieleicht nicht wirklich elegeant, aber es geht zumindest mal ;)

Thx für eure Hilfe,
greets ben

Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Do 30.03.06 09:51 
Moin :-)
Dein Code und das Beispiel von user profile iconUGrohne ergibt das
ausblenden Delphi-Quelltext
1:
2:
 if SMDBGrid1.Columns[5].Field.DataType = ftBoolean then
   SMDBGrid1.Columns[3].field.ReadOnly := (SMDBGrid1.Columns[5].Field.Text = 'True');