TForm有(继承下来的)Controls属性和Components属性,.NET的System.Windows.Forms.Form有没有对应的?

ooolinux 2017-07-29 11:31:07
TForm有(继承下来的)Controls属性和Components属性,
.NET的System.Windows.Forms.Form有Controls属性,有没有和TForm的Components属性对应的?
...全文
247 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ooolinux 2017-08-01
  • 打赏
  • 举报
回复
引用 6 楼 DelphiGuy 的回复:
[quote=引用 4 楼 u010165006 的回复:] [quote=引用 3 楼 DelphiGuy 的回复:] 有Form.Container.Components属性,不过这似乎是Delphi中xxx.Owner.Components
Form.Container.Components属性怎么用呢? 比如这段代码,怎么改成Container.Components:
            int i = 1;
            foreach(Control c in this.Controls)
            {
                if(c is Button)
                {
                    c.Size=new Size(100,25);
                    c.Tag = i;
                    c.Text = "我是按钮"+i++;
                    c.BackColor = Color.FromArgb(0, 255, 255);
                    c.Click += button_Click;

                }
            }
[/quote] 你这段代码用的是Controls,.net的Form也有这属性。 [/quote] 这段代码,Panel里面的Button就作用不到了,如果想作用到,怎么改呢?
  • 打赏
  • 举报
回复
引用 4 楼 u010165006 的回复:
[quote=引用 3 楼 DelphiGuy 的回复:] 有Form.Container.Components属性,不过这似乎是Delphi中xxx.Owner.Components
Form.Container.Components属性怎么用呢? 比如这段代码,怎么改成Container.Components:
            int i = 1;
            foreach(Control c in this.Controls)
            {
                if(c is Button)
                {
                    c.Size=new Size(100,25);
                    c.Tag = i;
                    c.Text = "我是按钮"+i++;
                    c.BackColor = Color.FromArgb(0, 255, 255);
                    c.Click += button_Click;

                }
            }
[/quote] 你这段代码用的是Controls,.net的Form也有这属性。
ooolinux 2017-08-01
  • 打赏
  • 举报
回复
引用 8 楼 DelphiGuy 的回复:
应该c是Control就递归吧,对.net开发我也是二把刀。
是.net有些东西不如Delphi、CB方便。
  • 打赏
  • 举报
回复
应该c是Control就递归吧,对.net开发我也是二把刀。
ooolinux 2017-07-31
  • 打赏
  • 举报
回复
引用 3 楼 DelphiGuy 的回复:
有Form.Container.Components属性,不过这似乎是Delphi中xxx.Owner.Components
感觉还是很不同的。
ooolinux 2017-07-31
  • 打赏
  • 举报
回复
引用 3 楼 DelphiGuy 的回复:
有Form.Container.Components属性,不过这似乎是Delphi中xxx.Owner.Components
Form.Container.Components属性怎么用呢? 比如这段代码,怎么改成Container.Components:
            int i = 1;
            foreach(Control c in this.Controls)
            {
                if(c is Button)
                {
                    c.Size=new Size(100,25);
                    c.Tag = i;
                    c.Text = "我是按钮"+i++;
                    c.BackColor = Color.FromArgb(0, 255, 255);
                    c.Click += button_Click;

                }
            }
  • 打赏
  • 举报
回复
有Form.Container.Components属性,不过这似乎是Delphi中xxx.Owner.Components
ooolinux 2017-07-31
  • 打赏
  • 举报
回复
引用 1 楼 DelphiGuy 的回复:
因为托管代码程序在运行时是自动GC的,所以应该没有这种owner的概念。
那如果要遍历一个窗体上的所有Button控件,如果有的Button不是以窗体作为Parent,就比较麻烦了?
  • 打赏
  • 举报
回复
因为托管代码程序在运行时是自动GC的,所以应该没有这种owner的概念。
uses winskindlg; Type TMySkinManage=class(TSkinManage); procedure TForm1.btn1Click(Sender: TObject); //破解后的2.6版不能够动态改变窗体的caption,下面是补充解决办法 var P: Pchar; begin P := Pointer(TMySkinManage(SkinManager).FindSkinForm(Handle)); if P = nil then exit; P := P+104; //D5的话请将104改为88,未经测试 Pstring(P)^ := 'Edit1.Text'; Caption := 'Edit1.Text'; ////////////////////////////////////////////// end; Delphi VclSkin 2.60 VCLSkin is an VCL library that extend Delphi application with skinnable user interface . Unlike other skin component that you must modify source code to build skinnable application, VCLskin can skin existing application using VCL components without source code modification. VclSkin automatically skin kinds of windows in application, include Delphi forms,MDIform and common Windows dialogs (MsgBox,Open/Save,Font,Print), even the Exception MsgBox. Vclskin not only support Delphi standard controls, but also support many third-party component, such as TMS Grid pack, EnLib Grid, Developer Express QuantumGrid. It is an excellent choice for those wanting to skin existing applications. The cool thing is that it uses existing VCL components. Demo version adds a string 'VclSkin demo' on form caption, but allows to test all available functions. News in 2.60 *Support Arabic language, BiDiMode is righttoleft. *Fixed some bugs when application closed. News in 2.55 *Fixed bug that Tspeedbutton destory at runtime. *Improve performance when change menutitem at runtime. *Fixed OpenDialog bug. News in 2.50 *Support LMD tools. *Fixed bug of checkbox that is disabled . *Add TSkindata.Skin3rd property to add 3rd control easily. News in 2.45 *Some bugs fixed. *Improve compatibility with Billenium effects. News in 2.4 *Support to skin an application but keep the menu bar and title bar the default Windows standard. *DBCheckbox bug fixed. *Fixed bug in cascade,tile command in MIDform. *Bug with minimized state when form created. *Suport ReportBuilder News in 2.3 *Support TUpDown and TSpinEdit. *Support TrackBar. *Restore form size when remove skin. *Fix more bugs. News in 2.25 *Fix bug with QuickReport and FastReport. *Fix bug in Tstatusbar. *Fix bug in Application. News in 2.20 *Support Header control in TlistView. *Fix Menuitem ShortCut bug. *Fix bug that change windows Z-Order when skin change at runtime. *Support Tframe created at runtime. News in 2.10 *Fix Scrollbar drag thumb problem. News in 2.05 *Support multi-skindata in application,Mainform and messagebox can use different skindate. *Nested form support. *Fixed Title flicker problem when form resize. *Support Mainmenu change at runtime. News in 2.0 *skin kinds of windows in your project, Delphi forms,MDIform and common Windows dialogs (MsgBox,Open/Save,Font,Print), even the Exception MsgBox. *Enable/Disable skin at runtime. *fixed many bugs in MDIform. *system menu enchanced. website : http://www.link-rank.com email : info@link-rank.com

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧