Autor Beitrag
Flash106
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:13 
Hallo

ich versuche mich gerade ein wenig in der komponentenentwicklung und hab jetz ein eigenes Editfeld gemacht. Es soll eine Property namens tabelle haben aber ich kriege immer eine fehler meldung. hier mal der source:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
type
  TmyCustomEdit = class(TWinControl)
  private
    edEdit: TEdit;
    ...
    procedure SetTableName(vTable: String);
    function GetTableName: String;
    ...
  published
    property Text: String read GetText write SetText;  //<--das geht
    property Table: String read GetTableName write SetTableName;  //<-- das geht auch 
                                                            aber da unten nicht mehr
  end;
  ...
  ...

function TMyCustomEdit.GetTableName: String;
begin
  Result := edEdit.Table; //<-- jetz krieg ich den fehler das er table nicht kennt :(
end;

procedure TMyCustomEdit.SetTableName(vTable: String);
begin
  edEdit.Table := vTable;
end;


mit Text gehts doch auch :( ... was ist denn falsch daran??

hiiilfeee

Bianca

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Mo 27.12.2004 um 14:27
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 25.12.04 21:19 
Kann auch nicht gehen, denn du greifst auf Table als Eigenschaft von TEdit (edEdit) zu, und TEdit hat kein Table.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:20 
ähm naja.. ich dachte.. also ich wollt ihm sone eigenschaft verpassen.. geht das denn nicht? :(
ich mach das zum erstenmal.. sorry..
:(
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 25.12.04 21:25 
Klar geht das. Leite deine Komponente ganz einfach von TEdit ab anstatt von TWinControl, lass Table da, wo es jetzt ist (published), und gib deiner Kompo noch eine private Eigenschaft FTable zur internen Verwendung. Ein Komponenten-mach-Tutorial gibts glaub ich auf delphi-source.de (bin jetzt zu faul zum suchen).

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:28 
ok danke.. naja das auf delphi source hab ich mir angesehen... hab da nur nich so recht gefunden was ich gesucht hab... bis dann =).. schönen feiertage noch
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:31 
also laut tutorial müsste es ja dann so sein oder?? :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TmyCustomEdit = class(TEdit)
  private
    edEdit: TEdit;
    FTable : string;
...

  published
    property Text: String read GetText write SetText;
    property Table: String read FTable write FTable;
...


krieg aber immernoch den gleichen fehler :(

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 25.12.04 21:39 
Flash106 hat folgendes geschrieben:

ausblenden Quelltext
1:
2:
3:
4:
function TMyCustomEdit.GetTableName: String;
begin
  Result := edEdit.Table; //<-- jetz krieg ich den fehler das er table nicht kennt :(
end;


Result := edEdit.table ? das kann doch gar nicht gehen, table ist ja kein Element von edEdit1
wenn schon dann einfach table (aber ist table ein string???)
oder TMyCustomEdit.table
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:46 
ja also:

property Table: String read FTable write FTable;

puh.. ich möchte einfach Table als eigenschaft zu dem editfeld hinzufügen so wie text oder width oder was weis ich?! wie mache ich das denn fehlerfrei?!?!?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 25.12.04 21:50 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
type
  TmyCustomEdit = class(TEdit)
  private
  //   Table: string;
    ...
    procedure SetTableName(vTable: String);
    function GetTableName: String;
    ...
  published
    property Text: String read GetText write SetText;  //<--das geht
    property Table: String read GetTableName write SetTableName;  //<-- das geht auch 
                                                            aber da unten nicht mehr
  end;
  ...
  ...

function TMyCustomEdit.GetTableName: String;
begin
  Result := Table; //<-- jetz krieg ich den fehler das er table nicht kennt :(
end;

procedure TMyCustomEdit.SetTableName(vTable: String);
begin
  Table := vTable;
end;

probiers mal so
in deinem hauptprogramm musst du dann noch die unit einbinden und eine var vom type TMyCustomEdit definieren
var
edEDIT1 : TMyCustomedit;
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Sa 25.12.04 21:57 
nein geht nich... :cry:
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 25.12.04 21:59 
am einfachsten ginge es wenn du keine eigene "Komponente" machst, sondern einfach den Typ TMyCustomEdit in deinem Hauptprogramm definierst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type TMyCustomEdit = class(Tedit)
     private 
         table: string;
         text: string;
     end;
 
     TForm1 = Class (TForm)
  ...

var Form1 : TForm1;
    Eddt : TMyCustomEdit;

...

procedure Button1Click(sender... bla
begin
   Eddt.Text := 'bla';
   Eddt.table := 'tabelle1';
end;
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 25.12.04 22:04 
Flash106 hat folgendes geschrieben:
nein geht nich... :cry:

hast du in meinem CodeBeispiel die Zeile 4 auch auskommentiert ? ich habe das 3 min später oder so editiert


Ansonsten muss in den Private Teil folgendes kommen
FTable : string;
und unten
property Table: String read FTable write SetTableName;