G
Guest
Ok I'm having a problem with a listview. I have a listview on a WinForm
called ProgramInformationFrm. 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.Visible = False
ProgramInformationFrm.ProgramsLV.SelectedItems.Clear()
ProgramInformationFrm.ProgramsLV.Items.Clear()
Dim item As New ListViewItem(tmpNCFile)
ProgramInformationFrm.ProgramsLV.Items.Add(item)
ProgramInformationFrm.ProgramsLV.Focus()
ProgramInformationFrm.ProgramsLV.Items(0).Selected = True
ProgramInformationFrm.ShowDialog()
called ProgramInformationFrm. 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.Visible = False
ProgramInformationFrm.ProgramsLV.SelectedItems.Clear()
ProgramInformationFrm.ProgramsLV.Items.Clear()
Dim item As New ListViewItem(tmpNCFile)
ProgramInformationFrm.ProgramsLV.Items.Add(item)
ProgramInformationFrm.ProgramsLV.Focus()
ProgramInformationFrm.ProgramsLV.Items(0).Selected = True
ProgramInformationFrm.ShowDialog()