http://www.delphipages.com/forum/showthread.php?t=170787 À» Âü°íÇϸé
ÀÌ°ÍÀº µÇ°í...
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
s := '10001';
ComboBox1.Items.AddObject('a',TObject(s) );
s := '10002';
ComboBox1.Items.AddObject('b',TObject(s) );
s := '10003';
ComboBox1.Items.AddObject('c',TObject(s) );
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
label1.Caption := String( ComboBox1.Items.Objects[ComboBox1.ItemIndex] );
end;
ÀÌ°ÍÀº ¾ÈµÇ¿ä...
procedure TForm1.Button1Click(Sender: TObject);
begin
ComboBox1.Items.AddObject('a',TObject('10001') );
ComboBox1.Items.AddObject('b',TObject('10002') );
ComboBox1.Items.AddObject('c',TObject('10003') );
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
label1.Caption := String( ComboBox1.Items.Objects[ComboBox1.ItemIndex] );
end;
https://www.thoughtco.com/store-a-string-or-an-object-1058392 Âü°í(±¸±Û¹ø¿ª ÀÌ¿ëÇÏ¸é µË´Ï´Ù. ^^) ÇÏ¿© ¿Ö ¾ÈµÇ´ÂÁö... ÀÌÀ¯¸¦ ºÙÀÌÀÚ¸é...
" A direct typecast from an integer to an object is made above. The "AObject" parameter is actually the 4-byte pointer (address) of the object added. Since in Win32 an integer occupies 4 bytes - such a hard cast is possible. "
s := '10001';
ComboBox1.Items.AddObject('a',TObject(s) );
ÀÌ°ÍÀº ¹®ÀÚ¿ÀÇ ÁÖ¼Ò°¡ TObject ¿¡ Àü´ÞµÇ´Â °ÍÀÌ°í?
ComboBox1.Items.AddObject('a',TObject('10001') );
Àº Çüº¯È¯À» ½ÃµµÇÏ´Â °Í? ( stringÀ» 4byte Integer·Î typecast ¾ÈµÇ¹Ç·Î... )
À§ ¿¡°ÍÀ» ±×³É ³» »ý°¢ÀÔ´Ï´Ù. °ËÁõÀÌ ÇÊ¿äÇÕ´Ï´Ù~.
2019-05-23 ¿ÀÈÄ 10:33:39