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() 2 6268
On Mon, 13 Mar 2006 06:59:27 -0800, Mike
<Mi**@discussio ns.microsoft.co m> wrote: 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 ProgramSearc h 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.Visi ble = 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 ProgramInforma tionFrm.ShowDia log()
1) Focus() (ProgramsLV.Foc us()) usually has no meaning before a form
is displayed as that is usually determined by what control on the form
has the TabStop Index of "0", or, focus of a particular control is
called in the form's activated event.
(Note: In VB6, changing a TabIndex in a control reindexed the other
controls that had a TabIndex. I don't know about earlier versions,
but in VB2005, changing a TabIndex of a control does not reindex the
others, so you can wind up with more than one control with the same
index value and unpredicitable results.)
2) Run the .exe in bin\debug a couple of time and see if you are
getting the expected value results.
Gene
Ok got it working. To pass the value I am doing this;
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.Items(0).Sel ected = True
ProgramInformat ionFrm.Programs LV.Select()
ProgramInformat ionFrm.Programs LV.Items(0).Foc used = True
ProgramInformat ionFrm.ShowDial og()
On form load of ProgramInformat ionFrm I know use
tmpNCFile = Me.ProgramsLV.I tems(0).Text instead of
Me.ProgramsLV.S electedItems.It em(0).text to return value of the first item
in the list.
"gene kelley" wrote: On Mon, 13 Mar 2006 06:59:27 -0800, Mike <Mi**@discussio ns.microsoft.co m> wrote:
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 ProgramSearc h 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.Visi ble = 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 ProgramInforma tionFrm.ShowDia log()
1) Focus() (ProgramsLV.Foc us()) usually has no meaning before a form is displayed as that is usually determined by what control on the form has the TabStop Index of "0", or, focus of a particular control is called in the form's activated event. (Note: In VB6, changing a TabIndex in a control reindexed the other controls that had a TabIndex. I don't know about earlier versions, but in VB2005, changing a TabIndex of a control does not reindex the others, so you can wind up with more than one control with the same index value and unpredicitable results.)
2) Run the .exe in bin\debug a couple of time and see if you are getting the expected value results.
Gene This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom |
last post by:
For some strange reason my WinForms app occasionally
throws a System.NullReferenceException upon invoking the
Clear() method. The app will work fine for a long period
of time and then all of a sudden this exeption is thrown
and after that you just cant ever clear the ListView
control again - even though messages still go into it and
are displayed correctly.
Anybody have any idea what could be causing this?
|
by: Maheshkumar.R |
last post by:
hi groups,
I have placed an listview control, i want to iterate thru the control and find the clicked event items.
listView2.Items.Add(fname.ToString(), i);
how i can perform the iteration to find the item clicked...? and its item.
thankz--
Mähésh Kumär. R
|
by: Dinesh Jain |
last post by:
Hi all,
I encountered a strange problem with listview.
Sometimes(not always)even if one item is selected in
listview, still listview.selectedItems.count returns 0.
What can be the reason ?
I have just changed it's hideSelection property to
false and nothing else.
Please help,
Thanks in advance,
|
by: StriderBob |
last post by:
Situation :
FormX is mdi child form containing 2 ListViews
ListView1 contains a list of table names and 4 sub items with data about
each table.
ListView2 contains a list of the columns on each table and 11 sub items with
data about each column.
When a Row in ListView1 is selected the Data in ListVies2 is loaded to show
the correct data. Initially the first row in ListView1 is selected in FormX
load
|
by: John Devlon |
last post by:
Hi,
Does anyone know how to get a value of a second column of a selected item
in Listview.
I've create a listview and added this code
Listview.Items.Clear()
Listview.Columns.Clear()
Listview.View = View.Details
| |
by: John Devlon |
last post by:
Hello,
Does anyone know how to deselect all items in a listview ?
Thanx
John
|
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= |
last post by:
Hi,
I've recently replaced a CheckedListBox control with a ListView control,
however I'm missing the SelectedItem set functionality, its equivalent in
ListView, SelectedItems, is only implemented as a getter. I really need a way
to programmatically be able to set the selected ListViewItem.
Anyone know how to do this?
Regards Jesper
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |