vb.net里没有像vb那样的控件数组.也就是说复制控件后粘贴没有提示你是否创建控件数组.
你可以试验下面的代码.
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() Partial Class Form1
#Region "Windows フォーム デザイナによって生成されたコード "
System.Diagnostics.DebuggerNonUserCode() Public Sub New()
MyBase.New()
'この呼び出しは、Windows フォーム デザイナで必要です.
InitializeComponent()
End Sub
'Form は、コンポーネント一覧に后処理を実行するために dispose をオーバーライドします.
System.Diagnostics.DebuggerNonUserCode() Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
MyBase.Dispose(Disposing)
'Windows フォーム デザイナで必要です.
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents _Command1_1 As System.Windows.Forms.Button
Public WithEvents _Command1_0 As System.Windows.Forms.Button
'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です.
'Windows フォーム デザイナを使って変更できます.
'コード エディタを使用して、変更しないでください.
System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me._Command1_1 = New System.Windows.Forms.Button
Me._Command1_0 = New System.Windows.Forms.Button
CType(Me.Command1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'_Command1_1
Me._Command1_1.BackColor = System.Drawing.SystemColors.Control
Me._Command1_1.Cursor = System.Windows.Forms.Cursors.Default
Me._Command1_1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.SetIndex(Me._Command1_1, CType(1, Short))
Me._Command1_1.Name = "_Command1_1"
Me._Command1_1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_1.TabIndex = 1
Me._Command1_1.Text = "Command1"
Me._Command1_1.UseVisualStyleBackColor = False
'_Command1_0
Me._Command1_0.BackColor = System.Drawing.SystemColors.Control
Me._Command1_0.Cursor = System.Windows.Forms.Cursors.Default
Me._Command1_0.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.SetIndex(Me._Command1_0, CType(0, Short))
Me._Command1_0.Name = "_Command1_0"
Me._Command1_0.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_0.TabIndex = 0
Me._Command1_0.Text = "Command1"
Me._Command1_0.UseVisualStyleBackColor = False
'Form1
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.Control
Me.Controls.Add(Me._Command1_1)
Me.Controls.Add(Me._Command1_0)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.Name = "Form1"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Text = "Form1"
CType(Me.Command1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
#End Region
End Class
'==========================================
Form1中的代码如下:
Friend Class Form1
Inherits System.Windows.Forms.Form
Dim i As Object
'按钮标题数组.
Dim cArr() As String = New String() {"A", "B", "C", "D", "E", "F", "G"}
For i = 0 To Me.Command1.Count - 1
Me.Command1(i).Text = cArr(i)
Next
使用SelectedIndexChanged事件
Private Sub cbxBigDept_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
dim strBM as string
strBM=cbxBigDept.selectedValue ' 获得当前大部门名称
Dim myConn as SqlConnection = new sqlconnection(".......")
myConn.Open()
Dim myCmd as string = "select 小部门 from 小部门表 Where 大部门='" strBM "'"
Dim myAdapter as SqlDataAdapter = new SqlDataAdapter(myCmd,myConn)
Dim myDataSet as DataSet = new DataSet
myAdapter.Fill(myDataSet)
Me.cbxSonDept.DataSource = myAdapter.Table(0)
Me.cbxSonDept.ValueMember = "小部门"
myConn.Close
End Sub
祝你成功!
源码给你,采纳 不谢
等下,我好想发现了什么 你是想用comb 控件来显示列数据?
这有点不切实际
用datagridview控件来显示吧(举个例子给你 excel 表)
dim xb as excel.workbook
dim xp as excel.application
dim column as long
Dim index As Integer = DataGridView1.Rows.Add()
xb=xp.workbook.open("你的excel数据表")
column=xb.columns.count
for j as integer= 1 to column
if xb.rows.cells(1,j)=comb1.selectedvalue then
DataGridView1.Rows(index).Cells(j - 1).Value = xp.rows("1").Cells(j - 1).Value
xb.close(true)
xp.close(true)
xb=nothing
xp=nothing
采纳后可以追问
一般来说:连接数据库这一块都做成DLL,这样方便
在配置文件app.config中加入
//m_SqlPath
存放SQL语句的XML文件
Dim
sqlHelper
As
New
SQLHelper("LotDBConnection")
sqlRead
ResourceHelper
ht
Hashtable
strSQL
String
Try
'设置SQL文参数
ht.Clear()
ht.Add(ColumnName.USER_ID.ToString,
Trim(Me.txtUserID.Text))
ht.Add(ColumnName.USER_NAME.ToString,
Trim(Me.txtUserName.Text))
'数据查询
=
sqlRead.GetSQLSentence("GetUserList",
m_SqlPath,
ht)
ds
sqlHelper.ExecuteDataSet(strSQL)
If
ds.Tables(0).Rows.Count
Then
MessageBox
.Show
("数据不存在");
Else
'数据绑定
dgvUserMeisai.DataSource
ds.Tables(0)
End
Catch
ex
Exception
(ex.Message
);
Finally
Nothing
比如说这样添加的计时器:
Dim Timer1 As New Timer
你要在合适的地方开始,比如窗体Load事件中,这样:
Timer1.Interval = 1000 '单位毫秒,1000毫秒=1秒
Timer1.Enabled = True '启用计时器
然后在代码窗口上方下拉列表里选择Timer1的Tick事件,自动添加代码:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
这是计时器触发的事件,每秒触发一次,今天这一节面输入循环判断是否有日程即可.提示:你可以用Now对象获取当前的日期和时间.
①.、.NET是一个平台,一个抽象的平台的概念.
.NET平台其本身实现的方式其实还是库,抽象层面上来看是一个平台.
本人理解的.NET核心就是.NET Framwork.
.NET Framework包括两个关键组成元素:
a.Common Language Runtime,公共语言运行时(CLR)-提供内在管理,代码安全性检测等功能
b..NET Framework Class Library,.NET框架类库(FLC)-提供大量应用类库,提高开发效率
学习.NET Framework 是所有.NET 开发人员都必须的,否则开发.NET程序永远都是停留在'外功'的招式,NET Framework 是.NET开发高手的'内功'修行之一.
程序设计语言仅仅是为了方便开发人员和计算机沟通的工具,虽然C#语法相对C和C++要多一些,但是相对来看C#语法都比较固定,这样使用起来却都很容易.我认可一位朋友说的,C#的语法更严谨!
这里回过来看看.NET和C#的关系,不得不提的是.NET程序的执行过程.
C#符合.NET CLR中的公共语言运行规范.CLS:common language specification,当然所有的.NET Language都是符合这个规范的例如:VB.NET、XAML和C++/CLI....等等.
VB.NET封装的程度更加高一些.比如可以很容易的使用集合类型.而到了C#就不得不写一个类,实现IList,ICollection和IEnumerable接口,然后再写方法.这样也就用C#实现了一个功能和VB.NET一样的集合类.也就是说,用VB.NET是半路出家,C#是从头开始.当然这也决定了在设计时的思路.
C#需要符合.NET CLS,是因为.NET CLR和JAVA 虚拟机类似,有一个中间语言共机器来执行.所有不同语言的.NET代码在执行前会被编译成同样的中间语言(MSIL),所以所有.NET支持语言都必须符合符合CLS规范.
以上就是土嘎嘎小编为大家整理的vb.net后期绑定的简单介绍vb.net后期绑定的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!