几个极难问题求解!!!请高手帮忙!!!500分相送!(300分)

  • 主题发起人 主题发起人 topboy
  • 开始时间 开始时间
T

topboy

Unregistered / Unconfirmed
GUEST, unregistred user!
1.Boolean在内存中占几个字节?

2.假设Item形式为String型。请问该属性的写方法如何定义的?
(好像列表框都有Item属性.)

3.如何以最简单的方法将Combobox与Edit相互对应起来。(比如有20个Combobox和20个Edit,要让Combobox1对应Edit1,Combobox2对应Edit2……)?
这题好像是用Combobox的tag属性对应edit的什么指针来着?
 
1)可以看帮助文档。
2)不知动态数组行不?
3)不知道你的意思,是不是让TComboBox.Text=TEdit.Text?(不会简单的方法)
 
1. 这个由操作系统决定,通常是1字节,用ShowMessage(IntToStr(sizeof(Boolean)));就能得到。

2.
Txxx = class
private
function Get(Index: Integer): string;
procedure Put(Index: Integer; Item: string);
public 或 published
property Items[Index: Integer]: string read Get write Put; default;
end;

3.是动态创建还是静态创建的? 可以有不同的方法,例如用Tag作索引关联,用Name作索引关联,
用控件数组,等等。
 
呵呵,不缺人才,就是3还不懂,能不能讲细点
特别是动态创建的话。
 
If you create components dynamically, try this please:

TForm1 = class(TForm)
private
FEditList: array[0..19] of TEdit; //it could be any type of component
FComboList: array[0..19] of TComboBox; //it could be any type of component
public
procedure CreateControls;
end;

procedure TForm1.createControls;
var
i: integer;
begin
for i := 0 to 19 do
begin
FEditList := TEdit.Create;
FEditList.Parent := Self;
FEditList.Tag := I;
.... //Assign FEditList.left, FEditList.Top etc.
FComboList := TComboBox.Create;
FComboList.Parent := Self;
FComboList.Tag := I;
....
end;

OK, if any event of component is fired, you can access the associated component easily.

procedure TForm1.EditClick(Sender: TObject);
var
iIndex: integer;
begin
iIndex := TComponent(Sender).Tag;
ShowMessage(Format('My tag is %d', [iIndex]));
//and the associated component could be FComboList[iIndex];
end;


Over.
 
1.由编译开关决定,是16bit对齐的话有可能站16bit(根据构造体不同而异),
8bit对齐就站一字节。
2.见adnil说
3.如果按照面向对象的方式,应该重载两个类,添加关联指向的指针(属性)。
如果只是一个工具程序,adnil的方法就很好了,靠算法就行了。
 
1.就一个字节。
 
后退
顶部