
正文
关于vb.net窗体失去的信息
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
我的vb.net2010项目的窗体设计器没有了怎么办啊,代码都在!求求大家给
PublicClassSimpleCalculatorInheritsSystem.Windows.Forms.Form#Region"Windows窗体设计器生成的代码"PublicSubNew()MyBase.New()'该调用是Windows窗体设计器所必需的。InitializeComponent()'在InitializeComponent()调用之后添加任何初始化EndSub'窗体重写处置以清理组件列表。ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean)IfdisposingThenIfNot(componentsIsNothing)Thencomponents.Dispose()EndIfEndIfMyBase.Dispose(disposing)EndSub'Windows窗体设计器所必需的PrivatecomponentsAsSystem.ComponentModel.IContainer'注意:以下过程是Windows窗体设计器所必需的'可以使用Windows窗体设计器修改此过程。'不要使用代码编辑器修改它。FriendWithEventsLabel1AsSystem.Windows.Forms.LabelFriendWithEventsTextBox1AsSystem.Windows.Forms.TextBoxFriendWithEventsButton1AsSystem.Windows.Forms.ButtonFriendWithEventsButton2AsSystem.Windows.Forms.ButtonFriendWithEventsButton3AsSystem.Windows.Forms.ButtonFriendWithEventsButton4AsSystem.Windows.Forms.ButtonFriendWithEventsButton5AsSystem.Windows.Forms.ButtonFriendWithEventsButton6AsSystem.Windows.Forms.ButtonFriendWithEventsButton7AsSystem.Windows.Forms.ButtonFriendWithEventsButton8AsSystem.Windows.Forms.ButtonFriendWithEventsButton9AsSystem.Windows.Forms.ButtonFriendWithEventsButton10AsSystem.Windows.Forms.ButtonFriendWithEventsButton11AsSystem.Windows.Forms.ButtonFriendWithEventsButton12AsSystem.Windows.Forms.ButtonFriendWithEventsButton13AsSystem.Windows.Forms.ButtonFriendWithEventsButton14AsSystem.Windows.Forms.ButtonFriendWithEventsButton15AsSystem.Windows.Forms.ButtonFriendWithEventsButton16AsSystem.Windows.Forms.ButtonPrivateSubInitializeComponent()Me.Label1=NewSystem.Windows.Forms.LabelMe.TextBox1=NewSystem.Windows.Forms.TextBoxMe.Button1=NewSystem.Windows.Forms.ButtonMe.Button2=NewSystem.Windows.Forms.ButtonMe.Button3=NewSystem.Windows.Forms.ButtonMe.Button4=NewSystem.Windows.Forms.ButtonMe.Button5=NewSystem.Windows.Forms.ButtonMe.Button6=NewSystem.Windows.Forms.ButtonMe.Button7=NewSystem.Windows.Forms.ButtonMe.Button8=NewSystem.Windows.Forms.ButtonMe.Button9=NewSystem.Windows.Forms.ButtonMe.Button10=NewSystem.Windows.Forms.ButtonMe.Button11=NewSystem.Windows.Forms.ButtonMe.Button12=NewSystem.Windows.Forms.ButtonMe.Button13=NewSystem.Windows.Forms.ButtonMe.Button14=NewSystem.Windows.Forms.ButtonMe.Button15=NewSystem.Windows.Forms.ButtonMe.Button16=NewSystem.Windows.Forms.ButtonMe.SuspendLayout()''Label1'Me.Label1.Location=NewSystem.Drawing.Point(16,16)Me.Label1.Name="Label1"Me.Label1.Size=NewSystem.Drawing.Size(48,16)Me.Label1.TabIndex=0Me.Label1.Text="结果:"''TextBox1'Me.TextBox1.Location=NewSystem.Drawing.Point(64,8)Me.TextBox1.Name="TextBox1"Me.TextBox1.Size=NewSystem.Drawing.Size(120,21)Me.TextBox1.TabIndex=1Me.TextBox1.Text=""''Button1'Me.Button1.Location=NewSystem.Drawing.Point(200,8)Me.Button1.Name="Button1"Me.Button1.Size=NewSystem.Drawing.Size(56,24)Me.Button1.TabIndex=2Me.Button1.Text="清空"''Button2'Me.Button2.Location=NewSystem.Drawing.Point(48,56)Me.Button2.Name="Button2"Me.Button2.Size=NewSystem.Drawing.Size(24,24)Me.Button2.TabIndex=3Me.Button2.Text="1"''Button3'Me.Button3.Location=NewSystem.Drawing.Point(88,56)Me.Button3.Name="Button3"Me.Button3.Size=NewSystem.Drawing.Size(24,24)Me.Button3.TabIndex=4Me.Button3.Text="2"''Button4'Me.Button4.Location=NewSystem.Drawing.Point(136,56)Me.Button4.Name="Button4"Me.Button4.Size=NewSystem.Drawing.Size(24,24)Me.Button4.TabIndex=5Me.Button4.Text="3"''Button5'Me.Button5.Location=NewSystem.Drawing.Point(48,88)Me.Button5.Name="Button5"Me.Button5.Size=NewSystem.Drawing.Size(24,24)Me.Button5.TabIndex=6Me.Button5.Text="4"''Button6'Me.Button6.Location=NewSystem.Drawing.Point(88,88)Me.Button6.Name="Button6"Me.Button6.Size=NewSystem.Drawing.Size(24,24)Me.Button6.TabIndex=7Me.Button6.Text="5"''Button7'Me.Button7.Location=NewSystem.Drawing.Point(136,88)Me.Button7.Name="Button7"Me.Button7.Size=NewSystem.Drawing.Size(24,24)Me.Button7.TabIndex=8Me.Button7.Text="6"''Button8'Me.Button8.Location=NewSystem.Drawing.Point(48,120)Me.Button8.Name="Button8"Me.Button8.Size=NewSystem.Drawing.Size(24,24)Me.Button8.TabIndex=9Me.Button8.Text="7"''Button9'Me.Button9.Location=NewSystem.Drawing.Point(88,120)Me.Button9.Name="Button9"Me.Button9.Size=NewSystem.Drawing.Size(24,24)Me.Button9.TabIndex=10Me.Button9.Text="8"''Button10'Me.Button10.Location=NewSystem.Drawing.Point(136,120)Me.Button10.Name="Button10"Me.Button10.Size=NewSystem.Drawing.Size(24,24)Me.Button10.TabIndex=11Me.Button10.Text="9"''Button11'Me.Button11.Location=NewSystem.Drawing.Point(48,152)Me.Button11.Name="Button11"Me.Button11.Size=NewSystem.Drawing.Size(24,24)Me.Button11.TabIndex=12Me.Button11.Text="0"''Button12'Me.Button12.Location=NewSystem.Drawing.Point(176,56)Me.Button12.Name="Button12"Me.Button12.Size=NewSystem.Drawing.Size(24,24)Me.Button12.TabIndex=13Me.Button12.Text="+"''Button13'Me.Button13.Location=NewSystem.Drawing.Point(176,88)Me.Button13.Name="Button13"Me.Button13.Size=NewSystem.Drawing.Size(24,24)Me.Button13.TabIndex=14Me.Button13.Text="-"''Button14'Me.Button14.Location=NewSystem.Drawing.Point(176,120)Me.Button14.Name="Button14"Me.Button14.Size=NewSystem.Drawing.Size(24,24)Me.Button14.TabIndex=15Me.Button14.Text="*"''Button15'Me.Button15.Location=NewSystem.Drawing.Point(176,152)Me.Button15.Name="Button15"Me.Button15.Size=NewSystem.Drawing.Size(24,24)Me.Button15.TabIndex=16Me.Button15.Text="/"''Button16'Me.Button16.Location=NewSystem.Drawing.Point(88,152)Me.Button16.Name="Button16"Me.Button16.Size=NewSystem.Drawing.Size(72,24)Me.Button16.TabIndex=17Me.Button16.Text="计算"''SimpleCalculator'Me.AutoScaleBaseSize=NewSystem.Drawing.Size(6,14)Me.ClientSize=NewSystem.Drawing.Size(264,190)Me.Controls.Add(Me.Button16)Me.Controls.Add(Me.Button15)Me.Controls.Add(Me.Button14)Me.Controls.Add(Me.Button13)Me.Controls.Add(Me.Button12)Me.Controls.Add(Me.Button11)Me.Controls.Add(Me.Button10)Me.Controls.Add(Me.Button9)Me.Controls.Add(Me.Button8)Me.Controls.Add(Me.Button7)Me.Controls.Add(Me.Button6)Me.Controls.Add(Me.Button5)Me.Controls.Add(Me.Button4)Me.Controls.Add(Me.Button3)Me.Controls.Add(Me.Button2)Me.Controls.Add(Me.Button1)Me.Controls.Add(Me.TextBox1)Me.Controls.Add(Me.Label1)Me.Name="SimpleCalculator"Me.Text="简单计算器"Me.ResumeLayout(False)EndSub#EndRegionPrivateSubTextBox1_TextChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)EndSubPrivateSubTextBox1_TabStopChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)EndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDimbtnAsButton'按钮类型的变量btn=sender'把产生该事件的按钮对象赋值给btnTextBox1.Text=TextBox1.Text+btn.Text'把该按钮的Text属性值连接到TextBox1中EndSubPrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton4_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton5_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton5.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton6_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton6.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton7_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton7.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton8_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton8.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton9_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton9.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton10_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton10.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton11_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton11.ClickDimbtnAsButtonbtn=senderTextBox1.Text+=btn.TextEndSubPrivateSubButton12_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton12.ClickDimbtnAsButtonbtn=sender'在文本框的Text属性后连接一个空格、本按钮的Text属性值和一个空格TextBox1.Text=TextBox1.Text+""+btn.Text+""EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickTextBox1.Text=""'清空文本框EndSubPrivateSubButton13_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton13.ClickDimbtnAsButtonbtn=senderTextBox1.Text=TextBox1.Text+""+btn.Text+""EndSubPrivateSubButton14_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton14.ClickDimbtnAsButtonbtn=senderTextBox1.Text=TextBox1.Text+""+btn.Text+""EndSubPrivateSubButton15_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton15.ClickDimbtnAsButtonbtn=senderTextBox1.Text=TextBox1.Text+""+btn.Text+""EndSubPrivateSubButton16_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton16.Click'发生错误转移到标号“ErrorPro”指定的行去执行错误处理程序OnErrorGoToErrorProDimrAsDecimal'保存计算结果的变量DimtAsString=TextBox1.Text'用于保存文本框中的算术表达式DimspaceAsInteger=t.IndexOf("")'搜索空格位置,如果没有空格vb.net窗体失去,返回值为0'字符串的取子符方法vb.net窗体失去,第二个参数小于0,则将产生错误号为5的异常,即过程参数不正确Dims1AsString=t.Substring(0,space)'通过取子串方法获得第一个运算数DimopAsString=t.Substring(space+1,1)'通过取子串方法获得运算符Dims2AsString=t.Substring(space+3)'通过取子串方法获得第二个运算数Dimarg1,arg2AsIntegerarg1=Val(s1):arg2=Val(s2)SelectCaseopCase"+":r=arg1+arg2Case"-":r=arg1-arg2Case"*":r=arg1*arg2Case"/":r=arg1/arg2CaseElseMsgBox("输入的运算符有误vb.net窗体失去!")ExitSubEndSelectTextBox1.Text=CStr(r)'显示结果ExitSub'退出过程ErrorPro:'错误处理程序块SelectCaseErr.NumberCase6'除数为零时,或运算溢出时的错误号MsgBox("算术运算溢出!",,"溢出提示")TextBox1.Focus()ExitSubCase5'Substring过程的参数不符合要求的错误号MsgBox("必须输入运算符和第二个运算数!",,"运算数少")ExitSubCaseElse'其它情况显示错误号和错误原因MsgBox("错误号为"Err.NumberChr(10)Chr(13)"错误原因:"Err.Description)ExitSubEndSelectEndSubEndClass
相关问答
Q1: vb窗体不见了
当 vb窗体不见了 发生时,一般情况都是被用户不小心关闭了而已,解决方法如下:
在右上角的工程那里双击对应的窗体即可(毕竟一个程序未必就一个窗体,万一你创建了几百个窗体呢)
Q2: VB.NET 窗体内的一个Panel容器失去焦点就自动隐藏
Public Class Form3 按下,显示控件,并获得焦点. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Visible = True TextBox1.Focus() End Sub 判断是否获得焦点. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox1.Focused = True Then MessageBox.Show("已经获得焦点了.") Else MessageBox.Show("已经失去焦点了.") End If End Sub 失去焦点后自动陷藏. Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus TextBox1.Visible = False End Sub End Class
Q3: VB.NET的Form的所有事件
名称
说明
Activated
当使用代码激活或用户激活窗体时发生。
AutoSizeChanged
当 AutoSize 属性更改时发生。
AutoValidateChanged
当 AutoValidate 属性更改时发生。
BackColorChanged
当 BackColor 属性的值更改时发生。(从 Control 继承。)
BackgroundImageChanged
当 BackgroundImage 属性的值更改时发生。(从 Control 继承。)
BackgroundImageLayoutChanged
当 BackgroundImageLayout 属性更改时发生。(从 Control 继承。)
BindingContextChanged
当 BindingContext 属性的值更改时发生。(从 Control 继承。)
CausesValidationChanged
当 CausesValidation 属性的值更改时发生。(从 Control 继承。)
ChangeUICues
焦点或键盘用户界面 (UI) 提示更改时发生。(从 Control 继承。)
Click
在单击控件时发生。(从 Control 继承。)
ClientSizeChanged
当 ClientSize 属性的值更改时发生。(从 Control 继承。)
Closed
关闭窗体时发生。
Closing
关闭窗体时发生。
ContextMenuChanged
当 ContextMenu 属性的值更改时发生。(从 Control 继承。)
ContextMenuStripChanged
当 ContextMenuStrip 属性的值更改时发生。(从 Control 继承。)
ControlAdded
在将新控件添加到 Control.ControlCollection 时发生。(从 Control 继承。)
ControlRemoved
在从 Control.ControlCollection 移除控件时发生。(从 Control 继承。)
CursorChanged
当 Cursor 属性的值更改时发生。(从 Control 继承。)
Deactivate
当窗体失去焦点并不再是活动窗体时发生。
Disposed
当通过调用 Dispose 方法释放组件时发生。(从 Component 继承。)
DockChanged
当 Dock 属性的值更改时发生。(从 Control 继承。)
DoubleClick
在双击控件时发生。(从 Control 继承。)
DragDrop
拖放操作完成时发生。(从 Control 继承。)
DragEnter
在将对象拖入控件的边界时发生。(从 Control 继承。)
DragLeave
将对象拖出控件的边界时发生。(从 Control 继承。)
DragOver
在将对象拖到控件的边界上发生。(从 Control 继承。)
EnabledChanged
在 Enabled 属性值更改后发生。(从 Control 继承。)
Enter
进入控件时发生。(从 Control 继承。)
FontChanged
在 Font 属性值更改时发生。(从 Control 继承。)
ForeColorChanged
在 ForeColor 属性值更改时发生。(从 Control 继承。)
FormClosed
关闭窗体后发生。
FormClosing
关闭窗体前发生。
GiveFeedback
在执行拖动操作期间发生。(从 Control 继承。)
GotFocus
在控件接收焦点时发生。(从 Control 继承。)
HandleCreated
在为控件创建句柄时发生。(从 Control 继承。)
HandleDestroyed
在控件的句柄处于销毁过程中时发生。(从 Control 继承。)
HelpButtonClicked
单击“帮助”按钮时发生。
HelpRequested
用户请求控件帮助时发生。(从 Control 继承。)
ImeModeChanged
在 ImeMode 属性更改后发生。(从 Control 继承。)
InputLanguageChanged
更改窗体的输入语言后发生。
InputLanguageChanging
当用户尝试更改窗体的输入语言时发生。
Invalidated
控件的显示要求重新绘制时发生。(从 Control 继承。)
KeyDown
在控件有焦点的情况下按下键时发生。(从 Control 继承。)
KeyPress
在控件有焦点的情况下字符、空格或退格键时发生。(从 Control 继承。)
KeyUp
在控件有焦点的情况下释放键时发生。(从 Control 继承。)
Layout
在控件应重新定位其子控件时发生。(从 Control 继承。)
Leave
在输入焦点离开控件时发生。(从 Control 继承。)
Load
在第一次显示窗体前发生。
LocationChanged
在 Location 属性值更改后发生。(从 Control 继承。)
LostFocus
在控件失去焦点时发生。(从 Control 继承。)
MarginChanged
当 Margin 属性更改时发生。
MaximizedBoundsChanged
在 MaximizedBounds 属性的值更改后发生。
MaximumSizeChanged
在 MaximumSize 属性的值更改后发生。
MdiChildActivate
在多文档界面 (MDI) 应用程序内激活或关闭 MDI 子窗体时发生。
MenuComplete
当窗体菜单失去焦点时发生。
MenuStart
当窗体菜单接收焦点时发生。
MinimumSizeChanged
在 MinimumSize 属性的值更改后发生。
MouseCaptureChanged
当控件失去鼠标捕获时发生。(从 Control 继承。)
MouseClick
用鼠标单击控件时发生。(从 Control 继承。)
MouseDoubleClick
用鼠标双击控件时发生。(从 Control 继承。)
MouseDown
当鼠标指针位于控件上并按下鼠标键时发生。(从 Control 继承。)
MouseEnter
在鼠标指针进入控件时发生。(从 Control 继承。)
MouseHover
在鼠标指针停放在控件上时发生。(从 Control 继承。)
MouseLeave
在鼠标指针离开控件时发生。(从 Control 继承。)
MouseMove
在鼠标指针移到控件上时发生。(从 Control 继承。)
MouseUp
在鼠标指针在控件上并释放鼠标键时发生。(从 Control 继承。)
MouseWheel
在控件有焦点且鼠标轮移动时发生。(从 Control 继承。)
Move
在移动控件时发生。(从 Control 继承。)
PaddingChanged
在控件空白区更改时发生。(从 Control 继承。)
Paint
在重绘控件时发生。(从 Control 继承。)
ParentChanged
在 Parent 属性值更改时发生。(从 Control 继承。)
PreviewKeyDown
在焦点位于此控件上的情况下,当有按键动作时发生(在 KeyDown 事件之前发生)。(从Control 继承。)
QueryAccessibilityHelp
在 AccessibleObject 为辅助功能应用程序提供帮助时发生。(从 Control 继承。)
QueryContinueDrag
在拖放操作期间发生,并且允许拖动源确定是否应取消拖放操作。(从 Control 继承。)
RegionChanged
当 Region 属性的值更改时发生。(从 Control 继承。)
Resize
在调整控件大小时发生。(从 Control 继承。)
ResizeBegin
窗体进入大小调整模式时发生。
ResizeEnd
窗体退出大小调整模式时发生。
RightToLeftChanged
在 RightToLeft 属性值更改时发生。(从 Control 继承。)
RightToLeftLayoutChanged
更改 RightToLeftLayout 属性值之后发生。
Scroll
用户或代码滚动工作区时发生。(从 ScrollableControl 继承。)
Shown
只要窗体是首次显示就发生。
SizeChanged
在 Size 属性值更改时发生。(从 Control 继承。)
StyleChanged
在控件样式更改时发生。(从 Control 继承。)
SystemColorsChanged
系统颜色更改时发生。(从 Control 继承。)
TabIndexChanged
此 API 支持 产品 基础结构,不能在代码中直接使用。 当 TabIndex 属性的值更改时发生。
TabStopChanged
当 TabStop 属性更改时发生。
TextChanged
在 Text 属性值更改时发生。(从 Control 继承。)
Validated
在控件完成验证时发生。(从 Control 继承。)
Validating
在控件验证时发生。(从 Control 继承。)
VisibleChanged
在 Visible 属性值更改时发生。(从 Control 继承。)
Q4: VB.NET窗体内容很多,会不会导致窗体最小化后在还原时很卡?
不会卡vb.net窗体失去的vb.net窗体失去,体一显示已经加载到内存vb.net窗体失去了vb.net窗体失去,所以最小化还原是一定不会卡的
不过窗体内容太多会导致以后修改时查找不方便
建议把不同项目分别写在模块中
关于vb.net窗体失去和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






