Ok I'm having a problem with a listview. I have a listview on a WinForm
called ProgramInformat ionFrm. I call this from from 2 other forms. One is
ProgramSearch Frm, the other is OpenNCFrm. The search form accepts criteria
from a user ans searches a sql table for any nc program that matches the
criteria. The open form gives the user a list of programs that have not been
added to table yet. Ok, enough background. What is happening is if I use the
search from and get 8 results the first item is selected per my code. Now I
close that form get into the add form, add a new record. It writes to the
table, clears the listview on the info table, and then shows the infofrom.
The item is not selected, but is the only item in the list. It should be
selected. Also in debug I still have the previous value from the first time
the form was shown.
Here's my code
OpenNCFrm.Visib le = False
ProgramInformat ionFrm.Programs LV.SelectedItem s.Clear()
ProgramInformat ionFrm.Programs LV.Items.Clear( )
Dim item As New ListViewItem(tm pNCFile)
ProgramInformat ionFrm.Programs LV.Items.Add(it em)
ProgramInformat ionFrm.Programs LV.Focus()
ProgramInformat ionFrm.Programs LV.Items(0).Sel ected = True
ProgramInformat ionFrm.ShowDial og()
called ProgramInformat ionFrm. I call this from from 2 other forms. One is
ProgramSearch Frm, the other is OpenNCFrm. The search form accepts criteria
from a user ans searches a sql table for any nc program that matches the
criteria. The open form gives the user a list of programs that have not been
added to table yet. Ok, enough background. What is happening is if I use the
search from and get 8 results the first item is selected per my code. Now I
close that form get into the add form, add a new record. It writes to the
table, clears the listview on the info table, and then shows the infofrom.
The item is not selected, but is the only item in the list. It should be
selected. Also in debug I still have the previous value from the first time
the form was shown.
Here's my code
OpenNCFrm.Visib le = False
ProgramInformat ionFrm.Programs LV.SelectedItem s.Clear()
ProgramInformat ionFrm.Programs LV.Items.Clear( )
Dim item As New ListViewItem(tm pNCFile)
ProgramInformat ionFrm.Programs LV.Items.Add(it em)
ProgramInformat ionFrm.Programs LV.Focus()
ProgramInformat ionFrm.Programs LV.Items(0).Sel ected = True
ProgramInformat ionFrm.ShowDial og()
Comment