如果我把PageControl1改成Form可不可以?
解决方案 »
- 现在还有必要学习API吗?
- TIpSocket中的BIND函数不能调用,请各位高手帮忙
- 请教:函数定义之 read / write
- 使用TDBGridEh出生的问题
- 一個奇怪的錯誤,有誰知道嗎?(重分相謝)
- 图片存储问题
- 怎么在DBGrid1+ADOQuery1里动态添加一个由其他字段计算出来的字段???
- 大哥,大姐,帮帮忙呀!关于执行一个dos下的批处理文件
- 关于close和free 的问题!
- 如何使PageControl的某一页不可见,包括这一页的标题也不可见,PageControl1.Pages[0].visible :=false达不到我要的效果阿,怎么办呢
- 有关DBGrid控件和时间控件的问题
- 编程高手资源转手
pagecontrol的control[i]是指pagecontrol的单个一页。
var
I: Integer;begin
Edit1.Parent:= PageControl1;
ComboBox1.Parent := PageControl1; for I := 0 to PageControl1.ControlCount-1 do
begin
if PageControl1.Controls[I] Is TEdit then
TEdit(PageControl1.Controls[I]).ReadOnly := True;
if PageControl1.Controls[I] Is TComboBox then
TComboBox(PageControl1.Controls[I]).Enabled := False;
end;
end;
(TEdit.parent := PageControl1.TableSheet1 and TComboBox.Parent := PageControl1.TableSheet1 ;)procedure proname(aControl:TwinControl);
var
I : Integer;
begin
for I := 0 to aControl.ControlCount - 1 do
begin
if aControl.Controls[I] Is TEdit then
TEdit(aControl.Controls[I]).ReadOnly := True
else if aControl.Controls[I] Is TComboBox then
TComboBox(aControl.Controls[I]).Enabled := False
else if aControl is TWinControl then
begin
ProName(TWinControl(aControl));
end;
end;
end;
ProName(Pagecontrol1);//在你需要的地方这样调用
PageCount是指明有多少个page页可不是有几个控件
你下面的那个程序应该好使啊!!
Edit.Parent是TabSheet不是PageControl1
所以要遍历TabSheet容器var
I, J: Integer;
begin
//(*
for I := 0 to PageControl1.PageCount - 1 do
for J := 0 to PageControl1.Pages[I].ControlCount - 1 do
begin
if PageControl1.Pages[I].Controls[J] is TEdit then
TEdit(PageControl1.Pages[I].Controls[J]).ReadOnly := True
else if PageControl1.Pages[I].Controls[J] Is TComboBox then
TComboBox(PageControl1.Pages[I].Controls[J]).Enabled := False;
end;
//*)
//==============================================================================
(*
for I := 0 to ComponentCount - 1 do
begin
if (Components[I] is TEdit) and (TEdit(Components[I]).Parent is TTabSheet) then
TEdit(Components[I]).ReadOnly := True
else if (Components[I] is TComboBox) and (TComboBox(Components[I]).Parent is TTabSheet) then
TComboBox(Components[I]).Enabled := False;
end;
//*)
end;
例如:
with TabSheet1 do
begin
for i:=0 to ControlCount-1 do
begin
if Controls[i] is TEdit then
tedit(Controls[i]).readonly:=true;
if Controls[i] is TComboBox then
TComboBox(Controls[i]).Enabled:=false;
end;
end;
end;
呵呵,谢谢您的教导啊;
还有啊,这个分你要不要啊?
begin
for i:=0 to ControlCount-1 do
begin
if Controls[i] is TEdit then
tedit(Controls[i]).readonly:=true;
if Controls[i] is TComboBox then
TComboBox(Controls[i]).Enabled:=false;
end;
end;
end;