方法一: Var I: Integer; Begin For I := To ComponentCount - Do //获取组件数量 Begin If Components[I] Is TWinControl Then Begin If (Components[I] As TWinControl).Focused Then Begin Self.Caption := (Components[I] As TWinControl).Name; Break; End; End; End; 方法二:
在WebForm中,可以使用反射将业务对象绑定到 ASP.NET 窗体控件.最近做Winform项目,也参考WebForm中的代码实现同样的功能. Winform没有提供类似WebForm中的FindControl方法,我于是用遍历控件的方式,写了一个类似WebForm中的这个方法,考虑到Winform中的很多控件放在Label.TabControl中,方法采用了递归的方式. Winform和Winform的控件也有些区别,如在Winform中,DateTimePicker取值是
一.概述 本文要实现的功能是:当窗体最大化时,控件的大小可以随窗体一起变化.开发环境,vs2010 c# winform,窗体名称采用默认的Form1. 2.把调整控件大小的方法放到一个类中:FormSetSelfAuto.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing;