你可以直接使用一个常量判断啊:比如const isTest=true
通过测试isTest的值来决定是设计还是运行态。在完成设计时,可以把isTest=False
通过测试isTest的值来决定是设计还是运行态。在完成设计时,可以把isTest=False
解决方案 »
- 结构体如何进行重新定义啊? 谢谢啊!
- 提问:我想用vb打开AUTO CAD的图片,只要整个图片可以浏览就行了不需要编辑的,怎么实现?
- 如何去掉WebBrowser控件的滚动条?
- 用excel打印,从数据库中调出数据,用excel打印,打印的是销售单,表颈,表尾及表体的框架都用excel画好,只是向excel表格中添内容,但是
- VSS中如何实现Multiple Check Out
- datagird用什么办法能比较容易的导到excel中去
- 求 MSDN 2003-JAN一张盘1.66 G ISO 光盘的盘符。
- 如何计算传输速度和剩余时间
- 数据库备份的小问题
- WindowsMediaPlayer的问题
- form1在load的时候想把form2也load,在form1的前面,可我用form2.show 0,form1发现焦点还在form1,怎吗使form1load 的时候把form2展现在前面,并使焦点也在 form2?
- 請問有誰知道怎樣把視頻采集卡的信號顯示在自己的程序,還有怎麼樣把視頻卡的以AVI或ASF文件錄制,謝
The information in this article applies to:Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0
Microsoft Visual Basic Control Creation, Professional, and Enterprise Editions for Windows, version 5.0--------------------------------------------------------------------------------
SUMMARY
When creating a UserControl in Visual Basic you may have code that you don't what to run when the control is on a Form at design-time, but you do want to run when the Form is in run-time. This article shows how to use the AmbientProperties Object to tell when a host container of a control is in design or run-time. MORE INFORMATION
When a UserControl is placed on a form, any constituent controls that are in the control are in run-time mode, not design-time mode. Usually this does not cause any trouble for the developer. But there are cases where you need to have an event happen only when the container for the UserControl is in run-time. The following example shows how to enable or disable a Timer control by testing to see if the container is in design-time or run-time.
Step-by-Step Example
Create a New Standard EXE project.
From the Project Menu, select Add UserControl.
Add a Timer and a Label control to the UserControl.
Add the Following Code to the UserControl: Private Sub Timer1_Timer()
Label1.Caption = Time()
End Sub Private Sub UserControl_Show()
If Ambient.UserMode Then 'We are in run-time
Timer1.Interval = 1000
Timer1.Enabled = True
Else 'We are in design-time
Timer1.Enabled = False
Label1.Caption = "design time"
End If
End Sub
Close the UserControl.
Add the UserControl to Form1.
Run the Form.
Close the Form.
The information in this article applies to:Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0
Microsoft Visual Basic Control Creation, Professional, and Enterprise Editions for Windows, version 5.0--------------------------------------------------------------------------------
SUMMARY
When creating a UserControl in Visual Basic you may have code that you don't what to run when the control is on a Form at design-time, but you do want to run when the Form is in run-time. This article shows how to use the AmbientProperties Object to tell when a host container of a control is in design or run-time. MORE INFORMATION
When a UserControl is placed on a form, any constituent controls that are in the control are in run-time mode, not design-time mode. Usually this does not cause any trouble for the developer. But there are cases where you need to have an event happen only when the container for the UserControl is in run-time. The following example shows how to enable or disable a Timer control by testing to see if the container is in design-time or run-time.
Step-by-Step Example
Create a New Standard EXE project.
From the Project Menu, select Add UserControl.
Add a Timer and a Label control to the UserControl.
Add the Following Code to the UserControl: Private Sub Timer1_Timer()
Label1.Caption = Time()
End Sub Private Sub UserControl_Show()
If Ambient.UserMode Then 'We are in run-time
Timer1.Interval = 1000
Timer1.Enabled = True
Else 'We are in design-time
Timer1.Enabled = False
Label1.Caption = "design time"
End If
End Sub
Close the UserControl.
Add the UserControl to Form1.
Run the Form.
Close the Form.