[VB.NET]vb.net databind combobox never lost focus?

作者在使用 VB.NET 进行应用程序开发时遇到了问题:当 ComboBox 绑定到数据库表后,无法通过点击切换到其他控件,也无法关闭窗体。代码中展示了 DetailsForm 的部分实现,包括控件绑定及窗体加载事件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VB.NET源码-156个实用实例哦…… <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
vb.net databind combobox never lost focus?
I set up a connection to a table books of a database.
================================
table fields

ISBN,
title,
cost

=======================================


I changed the ISBN number to a combobox and dragged and dropped down the whole table in details view to the form

================================


isbn: --------|
------- ^
^
title xxxxxxx


cost xxxxxxxxx

===============================

I deleted the navigation bar at the top.

I clicked on the smart tag and selected the data bind item checkbox. then I configured the datasource, display member and selected value.

Different books can be seen by selecting different isbn from the combobox.

However, I can not move my mouse to the cost textfield or title textfield on the form. Even worse, I can not close the form.

This is so wired.

Can anyone tell me why and how to solve this problem? I will give u the credits immediatelly if ur answer is valid.
__________________________________________________________________________
''Please see the code below

Public Class DetailsForm

Private Sub bindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Me.Validate Then
Me.BooksBindingSource.EndEdit()
Me.BooksTableAdapter.Update(Me.RnrBooksDataSet.Books)
Else
System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred. ", "Save ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
End If

End Sub

Private Sub DetailsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''TODO: This line of code loads data into the ''RnrBooksDataSet.Books '' table. You can move, or remove it, as needed.
Me.BooksTableAdapter.Fill(Me.RnrBooksDataSet.Books)

End Sub
End Class


_
Partial Public Class DetailsForm
Inherits System.Windows.Forms.Form

''Form overrides dispose to clean up the component list.
_
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub

''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

''NOTE: The following procedure is required by the Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
_
Private Sub InitializeComponent()
''
''Subject_CodeLabel
''
Subject_CodeLabel.AutoSize = True
Subject_CodeLabel.Location = New System.Drawing.Point(28, 148)
Subject_CodeLabel.Name = "Subject_CodeLabel "
Subject_CodeLabel.Size = New System.Drawing.Size(83, 12)
Subject_CodeLabel.TabIndex = 9
Subject_CodeLabel.Text = "Subject Code: "
''
''Shelf_LocationLabel
''
Shelf_LocationLabel.AutoSize = True
Shelf_LocationLabel.Location = New System.Drawing.Point(28, 173)
Shelf_LocationLabel.Name = "Shelf_LocationLabel "
Shelf_LocationLabel.Size = New System.Drawing.Size(95, 12)
Shelf_LocationLabel.TabIndex = 11
Shelf_LocationLabel.Text = "Shelf Location: "

''
''RnrBooksDataSet
''
Me.RnrBooksDataSet.DataSetName = "RnrBooksDataSet "
''
''BooksBindingSource
''
Me.BooksBindingSource.DataMember = "Books "
Me.BooksBindingSource.DataSource = Me.RnrBooksDataSet
''
''BooksTableAdapter
''
Me.BooksTableAdapter.ClearBeforeFill = True
''
''TitleTextBox
''
Me.TitleTextBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "Title ", True))
Me.TitleTextBox.Location = New System.Drawing.Point(109, 70)
Me.TitleTextBox.Name = "TitleTextBox "
Me.TitleTextBox.Size = New System.Drawing.Size(303, 21)
Me.TitleTextBox.TabIndex = 4
''
''AuthorTextBox
''
Me.AuthorTextBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "Author ", True))
Me.AuthorTextBox.Location = New System.Drawing.Point(109, 95)
Me.AuthorTextBox.Name = "AuthorTextBox "
Me.AuthorTextBox.Size = New System.Drawing.Size(303, 21)
Me.AuthorTextBox.TabIndex = 6
''
''PublisherTextBox
''
Me.PublisherTextBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "Publisher ", True))
Me.PublisherTextBox.Location = New System.Drawing.Point(109, 120)
Me.PublisherTextBox.Name = "PublisherTextBox "
Me.PublisherTextBox.Size = New System.Drawing.Size(303, 21)
Me.PublisherTextBox.TabIndex = 8
''
''Subject_CodeTextBox
''
Me.Subject_CodeTextBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "Subject_Code ", True))
Me.Subject_CodeTextBox.Location = New System.Drawing.Point(109, 145)
Me.Subject_CodeTextBox.Name = "Subject_CodeTextBox "
Me.Subject_CodeTextBox.Size = New System.Drawing.Size(303, 21)
Me.Subject_CodeTextBox.TabIndex = 10
''
''Shelf_LocationTextBox
''
Me.Shelf_LocationTextBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "Shelf_Location ", True))
Me.Shelf_LocationTextBox.Location = New System.Drawing.Point(109, 170)
Me.Shelf_LocationTextBox.Name = "Shelf_LocationTextBox "
Me.Shelf_LocationTextBox.Size = New System.Drawing.Size(303, 21)
Me.Shelf_LocationTextBox.TabIndex = 12
''
''FictionCheckBox
''
Me.FictionCheckBox.DataBindings.Add(New System.Windows.Forms.Binding( "CheckState ", Me.BooksBindingSource, "Fiction ", True))
Me.FictionCheckBox.Location = New System.Drawing.Point(109, 195)
Me.FictionCheckBox.Name = "FictionCheckBox "
Me.FictionCheckBox.Size = New System.Drawing.Size(104, 22)
Me.FictionCheckBox.TabIndex = 14
''
''ISBNComboBox
''
Me.ISBNComboBox.DataBindings.Add(New System.Windows.Forms.Binding( "Text ", Me.BooksBindingSource, "ISBN ", True))
Me.ISBNComboBox.DataSource = Me.BooksBindingSource
Me.ISBNComboBox.DisplayMember = "ISBN "
Me.ISBNComboBox.FormattingEnabled = True
Me.ISBNComboBox.Location = New System.Drawing.Point(109, 45)
Me.ISBNComboBox.Name = "ISBNComboBox "
Me.ISBNComboBox.Size = New System.Drawing.Size(303, 20)
Me.ISBNComboBox.TabIndex = 2
Me.ISBNComboBox.ValueMember = "ISBN "
''
''TextBox1
''
Me.TextBox1.Location = New System.Drawing.Point(157, 211)
Me.TextBox1.Name = "TextBox1 "
Me.TextBox1.Size = New System.Drawing.Size(199, 21)
Me.TextBox1.TabIndex = 15
''
.
.
End Class
__________________________________________________________________________
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值