重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
list1.additem j 意思就是把j添加至list1列表中,這是在一個(gè)for 循環(huán)中,循環(huán)了10次,添加了10次 j,即 list1 中 有10列分別為:1,3,6,10,15,21,28,36,45,55
目前成都創(chuàng)新互聯(lián)公司已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁(yè)空間、綿陽(yáng)服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、海安網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
下面又來(lái)了一個(gè)循環(huán), list1.removeitem 刪除列,刪除的是 list1.listcount - i ,list1.listcount 就是總列數(shù)為10,減去 i ,i 是1到4,即10-1,9-2,8-3,7-4 每減掉一次,list1.listcount 就少了一條記錄。
(注意,list1.listcount-1 是最后一條記錄)
減掉了第 9,7,5,3列
剩余為 1,3,6,15,28,45
結(jié)果為:3,15,28
'ListCount返回列表框中的項(xiàng)目總數(shù)
'ListCount-1是列表框中最后一個(gè)項(xiàng)目的索引號(hào)
'虧你提醒了,我寫錯(cuò)了,上面修改了,第一個(gè)索引為0,最后一個(gè)為9.
'也就是,問(wèn)題所問(wèn)的第二列的索引為1,第四列的索引為3...
數(shù)組內(nèi)容更新結(jié)束后,清空Datagridview,然后再重寫Datagridview就可以了、
vb.net里沒(méi)有像vb那樣的控件數(shù)組。也就是說(shuō)復(fù)制控件后粘貼沒(méi)有提示你是否創(chuàng)建控件數(shù)組。
你可以試驗(yàn)下面的代碼。
Form1.Designer.vb 設(shè)計(jì)器中的窗體代碼如下,上面有六個(gè)button。最右邊的用來(lái)改變前5個(gè)地text:
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() Partial Class Form1
#Region "Windows フォーム デザイナによって生成されたコード "
System.Diagnostics.DebuggerNonUserCode() Public Sub New()
MyBase.New()
'この呼び出しは、Windows フォーム デザイナで必要です。
InitializeComponent()
End Sub
'Form は、コンポーネント一覧に后処理を?qū)g行するために 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
End If
MyBase.Dispose(Disposing)
End Sub
'Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents Command2 As System.Windows.Forms.Button
Public WithEvents _Command1_4 As System.Windows.Forms.Button
Public WithEvents _Command1_3 As System.Windows.Forms.Button
Public WithEvents _Command1_2 As System.Windows.Forms.Button
Public WithEvents _Command1_1 As System.Windows.Forms.Button
Public WithEvents _Command1_0 As System.Windows.Forms.Button
Public WithEvents Command1 As Microsoft.VisualBasic.Compatibility.VB6.ButtonArray
'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。
'Windows フォーム デザイナを使って変更できます。
'コード エディタを使用して、変更しないでください。
System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.Command2 = New System.Windows.Forms.Button
Me._Command1_4 = New System.Windows.Forms.Button
Me._Command1_3 = New System.Windows.Forms.Button
Me._Command1_2 = New System.Windows.Forms.Button
Me._Command1_1 = New System.Windows.Forms.Button
Me._Command1_0 = New System.Windows.Forms.Button
Me.Command1 = New Microsoft.VisualBasic.Compatibility.VB6.ButtonArray(Me.components)
CType(Me.Command1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Command2
'
Me.Command2.BackColor = System.Drawing.SystemColors.Control
Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
Me.Command2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command2.Location = New System.Drawing.Point(235, 176)
Me.Command2.Name = "Command2"
Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command2.Size = New System.Drawing.Size(65, 25)
Me.Command2.TabIndex = 5
Me.Command2.Text = "Change"
Me.Command2.UseVisualStyleBackColor = False
'
'_Command1_4
'
Me._Command1_4.BackColor = System.Drawing.SystemColors.Control
Me._Command1_4.Cursor = System.Windows.Forms.Cursors.Default
Me._Command1_4.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.SetIndex(Me._Command1_4, CType(4, Short))
Me._Command1_4.Location = New System.Drawing.Point(16, 176)
Me._Command1_4.Name = "_Command1_4"
Me._Command1_4.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_4.Size = New System.Drawing.Size(93, 25)
Me._Command1_4.TabIndex = 4
Me._Command1_4.Text = "Command1"
Me._Command1_4.UseVisualStyleBackColor = False
'
'_Command1_3
'
Me._Command1_3.BackColor = System.Drawing.SystemColors.Control
Me._Command1_3.Cursor = System.Windows.Forms.Cursors.Default
Me._Command1_3.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.SetIndex(Me._Command1_3, CType(3, Short))
Me._Command1_3.Location = New System.Drawing.Point(16, 137)
Me._Command1_3.Name = "_Command1_3"
Me._Command1_3.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_3.Size = New System.Drawing.Size(93, 25)
Me._Command1_3.TabIndex = 3
Me._Command1_3.Text = "Command1"
Me._Command1_3.UseVisualStyleBackColor = False
'
'_Command1_2
'
Me._Command1_2.BackColor = System.Drawing.SystemColors.Control
Me._Command1_2.Cursor = System.Windows.Forms.Cursors.Default
Me._Command1_2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.SetIndex(Me._Command1_2, CType(2, Short))
Me._Command1_2.Location = New System.Drawing.Point(16, 96)
Me._Command1_2.Name = "_Command1_2"
Me._Command1_2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_2.Size = New System.Drawing.Size(93, 25)
Me._Command1_2.TabIndex = 2
Me._Command1_2.Text = "Command1"
Me._Command1_2.UseVisualStyleBackColor = False
'
'_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.Location = New System.Drawing.Point(16, 56)
Me._Command1_1.Name = "_Command1_1"
Me._Command1_1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_1.Size = New System.Drawing.Size(93, 25)
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.Location = New System.Drawing.Point(16, 16)
Me._Command1_0.Name = "_Command1_0"
Me._Command1_0.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._Command1_0.Size = New System.Drawing.Size(93, 25)
Me._Command1_0.TabIndex = 0
Me._Command1_0.Text = "Command1"
Me._Command1_0.UseVisualStyleBackColor = False
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(312, 213)
Me.Controls.Add(Me.Command2)
Me.Controls.Add(Me._Command1_4)
Me.Controls.Add(Me._Command1_3)
Me.Controls.Add(Me._Command1_2)
Me.Controls.Add(Me._Command1_1)
Me.Controls.Add(Me._Command1_0)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.Location = New System.Drawing.Point(4, 23)
Me.Name = "Form1"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Text = "Form1"
CType(Me.Command1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
End Class
’==========================================
Form1中的代碼如下:
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
Dim i As Object
'按鈕標(biāo)題數(shù)組。
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
End Sub
End Class
可以,按照下面的例子
listbox1.DataSource = ds.Tables(0)'綁定數(shù)據(jù)
listbox1.DisplayMember = "mainmen" 'listbox里顯示的內(nèi)容
listbox1.ValueMember = "bumen" '內(nèi)容對(duì)應(yīng)的值