下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、2014-12-22ContainerControl ClassProvides focus-management functionality for controls that can function as a container for other controls. Namespace : System.Windows.FormsAssembly : System.Windows.Forms (in System.Windows.Forms.dll)Syntax : public class ContainerControl : ScrollableControl, IContaine
2、rControlRemarks : A ContainerControl represents a control that can function as a container for other controls and provides focus management. Controls that inherit from this class can track the active control they contain, even when the focus moves somewhere within a different container.ContainerCont
3、rol objects provide a logical boundary for contained controls. The container control can capture the TAB key press and move focus to the next control in the collection.Note: The container control does not receive focus; the focus is always set to the first child control in the collection of containe
4、d controls.You do not typically inherit directly from the ContainerControl class. Form , UserControl , and UpDownBase classes inherit from ContainerControl.Properties:1、 ActiveControl:public Control型 , Gets or sets the active control on the container control.Remarks: The ActiveControl property activ
5、ates or retrieves the active control on the container control.In order to receive a valid value from this property, the object that calls it must either contain or be contained inthe control itiscalling. Ifoneformtries to call anotherform's ActiveControl properties,it willreceiveanundefined valu
6、e. In this case, you need to define your own communication mechanism between the forms to passthis data.2、 AutoScaleDimensions: publicSizeF 型 , Gets or sets the dimensions that the control was designed to.Remarks: The AutoScaleDimensions property represents the DPI or font setting of the screen that
7、 the control wasscaled to or designed for. Specifically, at design time this property will be set by the Windows Forms designer tothe value your monitor iscurrentlyusing. Then,whentheformloadsat run time, if theCurrentAutoScaleDimensionsproperty is different from the AutoScaleDimensions, thePerformA
8、utoScale methodwill be called to perform scaling of the control and all of its children. Afterwards, AutoScaleDimensions will beupdated to reflect the new scaling size.3、 AutoScaleFactor: protected SizeF 型 , Gets the scaling factor between the current and design-time automaticscaling dimensions.Rema
9、rks:The AutoScaleFactor propertyrepresentsthescalingfactorbetweenthe CurrentAutoScaleDimensionsand AutoScaleDimensionsproperties. Thisvalueiscalculatedwhenitisrequired. Forexample, if CurrentAutoScaleDimensions is(192, 144) and AutoScaleDimensionsis (96, 96) thenthe AutoScaleFactor is (2.0, 1.5).4、
10、AutoScaleMode: publicAutoScaleMode型, Gets orsets the automaticscalingmode ofthe control.Thedefault is None.Remarks: The AutoScaleMode propertyspecifies the current automaticscaling modeofthis control. Scalingby Font is useful if you want to have a control or form stretch or shrink according to the s
11、ize of the fonts in theoperating system, and should be used whenthe absolute size of the controlor formdoes not matter.Scalingby Dpi is useful when you want to size a control or form relative to the screen. For example, you may want to usedots per inch (DPI) scaling on a control displaying a chart o
12、r other graphic so that it always occupies a certainpercentage of the screen.5、 AutoValidate: public virtualAutoValidate 型 , Gets or sets a value thatindicates whether controls inthiscontainer will be automatically validated when the focus changes. The default isInherit .Remarks: The default value f
13、or AutoV alidate will differ for each control. For more details on implicit validation,see User Input Validation in Windows Forms .Setting this property to a new value will raise theAutoV alidateChanged event.6、 BindingContext: public override BindingContext型 , Gets or sets the BindingContext for th
14、e control.7、CanEnableIme: protected override bool 型 , Gets a value indicating whether theImeMode property can be set toan active value, to enable IME support.Remarks: In the .NET Framework 2.0 and later, IME functionality is handled by the framework and native IMEsupport for individual controls is d
15、isabled.A user control that derives fromthe ContainerControlclass can enable nativeIME support by overridingthisproperty to return true. However,the applicationis then responsible for makingsure that there are no conflictsbetween the native IME and the Windows Forms IME. This scenario is not support
16、ed.8、 CurrentAutoScaleDimensions: public SizeF 型 , Gets the current run-time dimensions of the screen.Remarks:The CurrentAutoScaleDimensions propertyrepresents the reference dimensions on the currentscreen. Incontrast, the AutoScaleDimensions propertyrepresents the design-time reference dimensions o
17、f thedesign environment for the current control, while theAutoScaleFactor property is the ratio of the two.The interpretation of the dimension value depends on theAutoScaleMode property in the following ways:If the mode is Dpi , this property represents the resolution of the screen, in dots per inch
18、.If the mode is Font, this property represents the average font character size in pixels.If the AutoScaleModeproperty is set to None, CurrentAutoScaleDimensions is set equal to AutoScaleDimensions .9、 ParentForm: publicForm 型 , Gets the form that the container control is assigned to. This property w
19、ill returnnull if the control is hosted inside of Internet Explorer or in another hosting context where there is no parent form.Methods:1、 public void PerformAutoScale(): Performs scaling of the container control and its children.Remarks: An explicit call to the PerformAutoScale method is typically
20、only required after programmatic changesto the layout during run time. PerformAutoScale is implicitly called from the OnLayout method. PerformAutoScale is recursive; each child control, if it is a container, will have its version of this method called when the container's version executes.For mo
21、re information about automatic scaling, see Automatic Scaling in Windows Forms.2、 protected override bool ProcessCmdKey(ref Message msg, Keys keyData): Processes a command key.Parameters:Msg: A Message, passed by reference, that represents the window message to process.keyData: One of the Keys value
22、s that represents the key to process.3、 protected virtual bool ProcessTabKey(bool forward): Selects the next available control and makes it the active control.If the parameterforward is true to cycle forward through the controls in the ContainerControl ; otherwise, false. Remarks: A control with its
23、 TabStop property set to false cannot be selected, so the next available control will be selected.4、 protected virtual void UpdateDefaultButton(): When overridden by a derived class, updates which button is the default button.Remarks:The ContainerControl classdoesnotprovideanimplementationforthe Upd
24、ateDefaultButton method. Classesthat inheritthismethodmustimplementUpdateDefaultButton toupdate the default button.5、publicboolValidate():Verifiesthevalueofthecontrollosingfocusbycausingthe Validating and Validated events to occur,in that order.Ifcalledfromthe Validating or Validated eventhandlers,
25、this method will always return false.Remarks: The Validate method validates the last child control that is not validated and its ancestors up through,but not including, the current container control. This overloaded version always performs validation, regardless ofthe value of the AutoValidate prope
26、rty of the control's parent. Therefore use it to unconditionally force validation.6 、 publicbool Validate(boolcheckAutoValidate): Verifiesthe value ofthecontrolthatislosingfocus;conditionally dependent on whether automatic validation is turned on.Ifthe Parameter checkAutoValidateis true,the valu
27、eof the AutoValidatepropertyisused todetermineifvalidationshouldbeperformed;if false,validationisunconditionallyperformed.Ifcalledfromthe Validating or Validated event handlers, this method will always return false.Remarks: The Validate method validates the last child control that is not validated a
28、nd its ancestors up through,butnot including,thecurrentcontainer control. This overloaded versionperformsvalidationbased onthefollowing conditions: If thecheckAutoValidate parameter is true, validation always occurs for child controls that are not validated.If the checkAutoValidate parameter is fals
29、e, validation occurs only if theAutoValidate property of the control'sparent is enabled.7、 publicvirtualbool ValidateChildren(ValidationConstraintsvalidationConstraints):Causes all ofthe childcontrols within a control that support validation to validate their data.The parameter validationConstra
30、ints is the places restrictions on which controls have their Validating event raised.If called from the Validatingor Validated event handlers, this method will always return false.Remarks: ValidateChildrenwillexamine allthe children of the current control, causing the Validatingevent tooccur on a co
31、ntrol if it meets the criteria spelled out byValidationConstraints .You may use several ValidationConstraintsparameters atoncebycombiningthem with a bitwise ORoperator. Combining parameters with a bitwise OR operator will result in a logical AND operation. For example,calling ValidateChildren(ValidationConstraints.ImmediateChildren|ValidationConstraints.Enabled) willonlyraise the Validating event on controls that are both immediate child
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年计算机程序员专业资格考试模拟试卷(含答案)
- 加气混凝土大板拼装工岗前工作技巧考核试卷含答案
- 柠檬酸发酵工安全知识能力考核试卷含答案
- 电解槽计算机监控工班组管理模拟考核试卷含答案
- 接插件装校工岗前核心能力考核试卷含答案
- 群众文化指导员岗中个人技能考核试卷含答案
- 园艺工岗前综合模拟考核试卷含答案
- 塑料层压工岗中趋势考核试卷含答案
- 滤棒成型设备操作工岗中理论水平考核试卷含答案
- 制浆工技能掌握评优考核试卷含答案
- 糖尿病非酮症高渗护理要点
- (一模)温州市2027届高三第一次适应性考试地理试卷(含答案)
- 2026年甘肃省天水市第二人民医院招聘编外工作人员67人考试模拟试题及答案解析
- 甘肃2024年冬季高中学业水平合格考数学试卷真题(含答案详解)
- 70周岁及以上驾驶人能力测试题库(含详细答案)
- 26新版五年级数学上册《课前预习单》
- 2026年高中体育会考模拟试卷及解析
- 2026年青少年学法用法知识竞赛考试题库(含答案)
- 2026年及未来5年市场数据中国游戏陪玩行业市场发展数据监测及投资前景展望报告
- 广东省安全监理用表(版省统表)
- 2025年法考真题及答案(完整版)
评论
0/150
提交评论