Listbox Selected Item Msgbox

Opening a msgbox for selected Listbox item

Page 1 of 1

4 Replies - 6538 Views - Last Post: 25 April 2009 - 08:47 AM Rate Topic: -----

#1 Dazastah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 15-April 09

Listbox Selected Item Msgbox

Post icon  Posted 21 April 2009 - 07:22 AM

I know this is simple but hard for me xD. Opening a msgbox when a listbox item is clicked
I was thinking something like

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		If ListBox1.SelectedItem = True Then
			MsgBox(ListBox1.ItemHeight, MsgBoxStyle.Information, "User")
		End If
	End Sub

It MUST contain the msgbox.
Any help is awesome and ily. Cheers.

Is This A Good Question/Topic? 0
  • +

Replies To: Listbox Selected Item Msgbox

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: Listbox Selected Item Msgbox

Posted 21 April 2009 - 08:04 AM

Use the list box's event "selected index change". Fire your message box from there.
Was This Post Helpful? 0
  • +
  • -

#3 sonia.sardana  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 132
  • Joined: 01-June 08

Re: Listbox Selected Item Msgbox

Posted 23 April 2009 - 10:19 PM

Public Class Form1

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim i As Integer
		Dim lvtem As ListViewItem

		For i = 1 To 5
			lvtem = ListView1.Items.Add(i)
			lvtem.SubItems.Add("sonia" & i)
			Application.DoEvents()
		Next

		ListView1.FullRowSelect = True


	End Sub

	Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
		Dim lvw As ListView = CType(sender, ListView)
		MsgBox(lvw.FocusedItem.Text & vbCrLf & lvw.FocusedItem.SubItems(1).Text)
	End Sub

 
End Class


Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: Listbox Selected Item Msgbox

Posted 24 April 2009 - 08:55 AM

That was not responsive. Try again.
Was This Post Helpful? 0
  • +
  • -

#5 Dazastah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 15-April 09

Re: Listbox Selected Item Msgbox

Posted 25 April 2009 - 08:47 AM

Thnx modi<3
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1