Whilst looping through items in a listview I wish to have the option of
inserting a new row (in the middle not necessarily at the end of the
listview).
thus if lvw is the listview name
dim itm as listviewitem
For each itm in lvw.Items
'if certain condition is met then insert new row in the listview here
'row must be inserted immediately under the current item
next itm
Thanks
Gerry 2 2465
This does the trick:
Dim itm As listviewitem
Dim MaxItems As Integer = lvw.Items.Count - 1 '0-based
Dim Counter As Integer
Do While Counter <= MaxItems
itm = lvw.Items(Count er)
If CInt(itm.Text.S ubstring(4, 2)) / 2 = CInt(CInt(itm.T ext.Substring(4 ,
2)) / 2) Then 'don't mind my "certain condition
'if certain condition is met then insert new row in the listview
here
'row must be inserted immediately under the current item
lvw.Items.Inser t(itm.Index, New ListViewItem("N ew item"))
Counter += 1
MaxItems += 1
End If
Counter += 1
Loop
Hope this helps,
Stefan
"dotnetnewb ie" <do**********@d iscussions.micr osoft.com> wrote in message
news:05******** *************** ***********@mic rosoft.com... Whilst looping through items in a listview I wish to have the option of inserting a new row (in the middle not necessarily at the end of the listview).
thus if lvw is the listview name
dim itm as listviewitem
For each itm in lvw.Items 'if certain condition is met then insert new row in the listview here 'row must be inserted immediately under the current item next itm
Thanks Gerry
thanks
the line
lvw.Items.Inser t(itm.Index, New ListViewItem("N ew item"))
was just what I was after.
Gerry
"Stefan De Schepper" wrote: This does the trick:
Dim itm As listviewitem Dim MaxItems As Integer = lvw.Items.Count - 1 '0-based Dim Counter As Integer Do While Counter <= MaxItems itm = lvw.Items(Count er) If CInt(itm.Text.S ubstring(4, 2)) / 2 = CInt(CInt(itm.T ext.Substring(4 , 2)) / 2) Then 'don't mind my "certain condition 'if certain condition is met then insert new row in the listview here 'row must be inserted immediately under the current item lvw.Items.Inser t(itm.Index, New ListViewItem("N ew item")) Counter += 1 MaxItems += 1 End If Counter += 1 Loop
Hope this helps, Stefan
"dotnetnewb ie" <do**********@d iscussions.micr osoft.com> wrote in message news:05******** *************** ***********@mic rosoft.com... Whilst looping through items in a listview I wish to have the option of inserting a new row (in the middle not necessarily at the end of the listview).
thus if lvw is the listview name
dim itm as listviewitem
For each itm in lvw.Items 'if certain condition is met then insert new row in the listview here 'row must be inserted immediately under the current item next itm
Thanks Gerry This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eva |
last post by:
Hi,
I wanted to know how i can enter values into a specific
column of a listview. I have tried the following code but
this seems to enter all my values into the first column!!!
Can anyone please help me out on this??
hers my code so far.....
|
by: J_Max |
last post by:
Hello,
This might be a really easy question, but... I am
developing a simple Smart Device application that uses a
listview. I have a function that adds a item to the
listview - code is below. I use the type listviewitem,
selitem, on one form to modify the listviewitem, using a
timer, every second, and use selitem1 to modify items,
after they have ended the time on the timer form, from
the form that the listview is located - this way I...
|
by: Anushya devi |
last post by:
Hi All
I used listview and tried to update it by using Addrange.
When the number of items is less, it works fine.. But I
need to update nearly 200,000 items and it hangs. Also i
need to add images to listview also(This is to list all
the items in my inbox, and want to give the user the feel
of outlook).
Since it hangs for even 1000 items in the inbox, i tried
to shift to virtual listview. But virtual listview
|
by: Andrew |
last post by:
If item is a ListViewItem and str is a string, why do the following two lines
not have the same effect ?
item.SubItems.Add(new ListViewItem.ListViewSubItem()).Text =
str;
item.SubItems.Add(str);
In the example code that follows, using the first line (in the ListView
constructor) causes the later redisplay of values (to some specified number
of decimal places) in the ListView not to work. Using the second line causes
|
by: John R. |
last post by:
I want to have a listbox that shows a checkbox and a textbox.
I created a user control that has a checkbox and a textbox in it and have
been trying to add it to a listbox but I can't get it to show up for each
item I add to the listbox.
foreach (Column column in columns)
{
ColumnsListBox.Items.Add(column.Name);
ColumnsListBox.Controls.Add(new ColumnListControl(true, column.Name,
| |
by: Holmes |
last post by:
Hello
Ran into a bit of a problem here and have now exhausted my resources to getting this working
What I am trying to do is load and show a simple vb form with a listbox in it
Dim frm_nc_code As New frm_nc_sen
frm_nc_code.Show(
Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
|
by: Ash Phillips |
last post by:
Hi Everyone,
I have this program I wrote in VB6 for family use. It's a DVD Database just
for me to keep track of them cause I have so many lol.
In VB6, I could add items to the ListView in 'frmMain' from 'frmAdd' with
the following code:
Private Function AddEntry(Title As String, Rating As String, Genre As
String, OnLoan As Boolean, ToWho As String)
|
by: Kadett |
last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control
at run-time and filling it with some records (let's say 10 000). This
operation seems to be quite fast, but when I call Controls.Add(list),
where list is my ListView control, then program hangs for minute. It seems
like this time depends on number of records added to control. So probably
when adding control to my form, those records are actualy added at this time...
|
by: Brandon McCombs |
last post by:
Hello,
I have a form that contains a listview on the left side and a column of
buttons on the right side. Only some of the buttons do I want enabled
all the time. The other buttons should be enabled only if something is
selected in the listview. That part specifically works but not very
well. It seems that I can only get the buttons to disable if I click off
the text of the items in the listview but still within about 10-20
pixels of...
|
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:
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |