C學(xué)習(xí)筆記ContainerControlClass_第1頁
C學(xué)習(xí)筆記ContainerControlClass_第2頁
C學(xué)習(xí)筆記ContainerControlClass_第3頁
C學(xué)習(xí)筆記ContainerControlClass_第4頁
免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論