Autor Beitrag
schnief7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 12.02.03 00:02 
Hallo

Wie kann ich denn den Data-Pointer von
ausblenden Quelltext
1:
TComboBoxEx.ItemsEx.Items[1].data					

verwenden??

Bitte helft mir

ein kleines Beispiel wäre super

danke schon mal

Moderiert von user profile iconTino: Code-Tags hinzugefügt.
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mi 12.02.03 10:44 
Was Willst Du den im Poinre ablegen ?

Also : Objekte oder Zeiger legst Du mit

ComboBoxEx.items.addobject('myItem',....) an

Zugriff auf die Objekte/Pointer erhälst Du mit :

Comboboex.items.objects[Index]

DAta

_________________
DataCool
schnief7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 12.02.03 12:16 
H!

Ich möchte jedem Item mehrere Variablen zuordnen.
Ich dachte über eine Record vielleicht!?


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
TExtItemData = record
  feldname: string;
  position: integer;
  id: integer;
  ...
end;


Kannst du mir bitte ein Beispiel für dieses addobject() geben??

Danke

Gruß schnief7
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mi 12.02.03 13:47 
Hi,

Du brauchst noch einen Zeiger auf den Record !

ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
type
  pExItemData = ^TExtItemData;
  TExtItemData = record 
    feldname: string; 
    position: integer; 
    id: integer; 
    ... 
  end;

Um einen Zeiger zu erzeugen mußt Du folgendermassen vorgehen :

Var pData : pExItemData;
begin
  New(pData);
  With pData^ do begin
    //Werte zuweisen
  end;
  // Zeiger in ComboBox ablegen
  myCombo.items.addobject('Anzeige-Namen',pData);
  // .....
  // Zeiger wieder auslesen(wahrscheinlich im OnChange Event der ComboBox

  if myCombo.itemindex > -1 then begin
    if myCombo.items.objects[myCombo.itemindex] <> Nil then begin
      pData := pExItemData(myCombo.items.objects[myCombo.itemindex]);
    end;
  end;

Was in diesem Bsp. nicht berücksichtigt wurde ist, dass für die Zeiger nur Speicher reserviert wurde mit New(s. oben), aber dieser Speicher muss bei Programmende wieder mit Dispose freigegeben werden.

Data

_________________
DataCool
schnief7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 12.02.03 16:57 
Danke!! Das funzt super!

Nur dass ich bei mir

addobject('Anzeige-Name',TObject(pData));

schreiben muss


Vielen Dank

Gruß