【老若】VB.net質問スレ【男女】
■ このスレッドは過去ログ倉庫に格納されています
0071.NETレス
NGNG基本的そのコードで問題ないみたいだけど。
以下、実際の実験コード。SDKでやってるので、いろいろ補足しますた。
環境:Win2000(SP2+SRP1)、IE6.0、.NET Framework SDK(SP1)(1.00.3705.209)
' コンパイルオプション
'vbc /t:winexe /r:System.dll /r:System.Drawing.dll
' /r:System.Windows.Forms.dll ListTest.vb /optionstrict+ /optimize+
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class ListTest
Inherits Form
Friend WithEvents ListBox1 As ListBox = New ListBox()
Friend WithEvents Button1 As Button = New Button()
Public Sub New()
Button1.Location = New Point(0,200)
Me.Controls.AddRange(New Control(){ListBox1,Button1})
End Sub
Public Shared Sub Main()
Application.Run(New ListTest())
End Sub
Public Sub List_Update()
Dim i As Integer
ListBox1.Items.Clear()
For i = 1 To 5
ListBox1.Items.Add(CStr(i))
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
List_Update()
End Sub
Private Sub ListBox1_SelectedItem(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles ListBox1.MouseDown
Dim s As String
s = CStr(ListBox1.SelectedItem)
MessageBox.Show(s)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
List_Update()
End Sub
End Class
■ このスレッドは過去ログ倉庫に格納されています