Re: vb.net ListBox Help

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 1 Dec 2007 12:48:36 -0500 (EST)

Data binding should be able to do what you want.  In examining the code,
it appears that a right parenthesis should be moved after ToString()
rather than before it.  Also, should it read SelectedIndex.ToString()
rather than SelectedItem.ToString()?  When declaring the ListBox, did
you use the WithEvents keyword?

Jamal
On Fri, 30 Nov 2007, Richard Thomas wrote:

> Date: Fri, 30 Nov 2007 08:09:29 -0500
> From: Richard Thomas <rthomas@xxxxxxxxxxx>
> Reply-To: programmingblind@xxxxxxxxxxxxx
> To: programmingblind@xxxxxxxxxxxxx
> Subject: vb.net ListBox Help
>
> Hi Guys:
> I bind a ListBox to a DataTable in a Load Event and load it.  This works 
> fine. I can arrow up and down and the entries are correct.
> I can not read the entries in the ListBox into a TextBox.
> Even though I arrow up and down the list and the IndexChanged event fires the 
> TextBox always shows the first entry in the list.
> Public Class frmStocksReport
> dim Dt As StockFDataSet.StocksDataTable
> Private Sub lbStocksReportNdx_SelectedIndexChanged( ByVal sender As 
> System.Object,  ByVal e As System.EventArgs) _
> Handles lbStocksReportNdx.SelectedIndexChanged
> MessageBox.Show( "item is " & lbStocksReportNdx.SelectedItem).ToString()
> Note: the above always shows the index as 0.' tbDescription.Text = _
> MessageBox.Show(  _
> DirectCast( _
> lbStocksReportNdx.SelectedItem, DataRowView)("Ticker").ToString())
> Note: The above always shows the first item's Ticker Symbol.
> End Sub
> Do I somehow need to synch the underlying DataView or DataTable to the 
> ListBox Selected Item somehow?
> Should I scrap the whole DataBinding senario?
> Any Ideas?
> Rick Farmington Mich. USA
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: