473,748 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading and Showing a Form before Adding Items to a Listview

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.Sho w(

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)

After the form is finished loading (or at least fully visible to the user), then I want the code to run where it adds about 500 items into this control. (why? because I would like to tell the user that the control is loading with info while its loading the info

Here is the code I use to add the items to the listview when the form is loading

Private Sub frm_nc_send_Loa d(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Loa
Me.lblStatus.Te xt = "FMS Buffer Loading...

listViewFiles.B eginUpdate(
listViewFiles.I tems.Clear(

Dim objDirectoryInf o = New DirectoryInfo(p ath_fms_buffer

Tr
Dim item As ListViewIte
For Each directory As DirectoryInfo In objDirectoryInf o.GetDirectorie
item = listViewFiles.I tems.Add(direct ory.Name
item.ImageIndex = iconList(direct ory.FullName
Nex
For Each file As FileInfo In objDirectoryInf o.GetFiles(
item = listViewFiles.I tems.Add(file.N ame
item.ImageIndex = iconList(file.F ullName
Nex
Catch ex As UnauthorizedAcc essExceptio
MessageBox.Show (Me, path_fms_buffer + " is not accessible" + System.Environm ent.NewLine + System.Environm ent.NewLine + "Access is denied.", path_fms_buffer , MessageBoxButto ns.OK, MessageBoxIcon. Stop
End Tr

listViewFiles.E ndUpdate(

Me.lblStatus.Te xt = "FMS Buffer Ready
End Su

Now everything works perfect, just the only problem is when i run the application. VB will add all the items while the form is loading THEN show the form, which is not how I would like it to operate. I would like the form to load and show with an empty listview box and then initiate a function or something where it begins loading the listview with items

Thanks to anyone who can shed some light on how to do this
Jessee Holmes
Nov 20 '05 #1
3 2612
Hi,

Try using a thread.

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

ListViewFiles.V iew = View.Details

Me.Text = "FMS BUFFER Loading"

Dim trdFiles As New System.Threadin g.Thread(Addres sOf LoadListView)

trdFiles.Start( )

End Sub

Public Sub LoadListView()

listViewFiles.B eginUpdate()

listViewFiles.I tems.Clear()

Dim path_fms_buffer As String = "C:\"

Dim objDirectoryInf o = New DirectoryInfo(p ath_fms_buffer)

Try

Dim item As ListViewItem

For Each directory As DirectoryInfo In objDirectoryInf o.GetDirectorie s

item = listViewFiles.I tems.Add(direct ory.Name)

' item.ImageIndex = iconList(direct ory.FullName)

Next

For Each file As FileInfo In objDirectoryInf o.GetFiles()

item = listViewFiles.I tems.Add(file.N ame)

'item.ImageInde x = iconList(file.F ullName)

Next

Catch ex As UnauthorizedAcc essException

MessageBox.Show (Me, path_fms_buffer + " is not accessible" +
System.Environm ent.NewLine + System.Environm ent.NewLine + "Access is
denied.", path_fms_buffer , MessageBoxButto ns.OK, MessageBoxIcon. Stop)

End Try

listViewFiles.E ndUpdate()

Me.Text = "FMS Buffer Ready"

End Sub

Ken

-----------------------

"Holmes" <jh*****@streme l.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
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_send
frm_nc_code.Sho w()

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).
After the form is finished loading (or at least fully visible to the user), then I want the code to run where it adds about 500 items into this
control. (why? because I would like to tell the user that the control is
loading with info while its loading the info)
Here is the code I use to add the items to the listview when the form is loading:
Private Sub frm_nc_send_Loa d(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Me.lblStatus.Te xt = "FMS Buffer Loading..."

listViewFiles.B eginUpdate()
listViewFiles.I tems.Clear()

Dim objDirectoryInf o = New DirectoryInfo(p ath_fms_buffer)

Try
Dim item As ListViewItem
For Each directory As DirectoryInfo In objDirectoryInf o.GetDirectorie s item = listViewFiles.I tems.Add(direct ory.Name)
item.ImageIndex = iconList(direct ory.FullName)
Next
For Each file As FileInfo In objDirectoryInf o.GetFiles()
item = listViewFiles.I tems.Add(file.N ame)
item.ImageIndex = iconList(file.F ullName)
Next
Catch ex As UnauthorizedAcc essException
MessageBox.Show (Me, path_fms_buffer + " is not accessible" + System.Environm ent.NewLine + System.Environm ent.NewLine + "Access is
denied.", path_fms_buffer , MessageBoxButto ns.OK, MessageBoxIcon. Stop) End Try

listViewFiles.E ndUpdate()

Me.lblStatus.Te xt = "FMS Buffer Ready"
End Sub

Now everything works perfect, just the only problem is when i run the application. VB will add all the items while the form is loading THEN show
the form, which is not how I would like it to operate. I would like the form
to load and show with an empty listview box and then initiate a function or
something where it begins loading the listview with items.

Thanks to anyone who can shed some light on how to do this,
Jessee Holmes

Nov 20 '05 #2
"Holmes" <jh*****@streme l.com> schrieb
Now everything works perfect, just the only problem is when i run the
application. VB will add all the items while the form is loading THEN
show the form, which is not how I would like it to operate. I would
like the form to load and show with an empty listview box and then
initiate a function or something where it begins loading the listview
with items.


Add this sub to your Form:

public shadows sub show
mybase.show
refresh

'move the code from the load event to /this/ location
end sub
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
AWESOME

It works

Great thank you for the help Armin and Ken. First, I tried Ken's solutions with the threading cause I kind of had an idea that that was what I was going to need to use, I tried it once before but couldn't get it to work

I'm not sure if armins code would have worked or not but thank you for the reply just the same

Everything works beautifully now

Much Appreciated
Jessee Holmes
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6127
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.....
20
6671
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)
7
10413
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname, while they are added to the treeview without the path (only file name). I'd like the user would be able to remove multiple items selecting filenames from the listview. So, items should be removed both from the listview and the treeview. How can I do...
2
2468
by: dotnetnewbie | last post by:
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
3
1379
by: Thomas Beyerlein | last post by:
I am writing code for a list box editor, one of the lists is large was hoping that there is a way to either speed it up by making the server do the IF statements of there is a faster way of checking the lists? Any help would be useful. Have posted the code I am using below Tom parentControl = New Windows.Forms.ListBox
6
1938
by: Josef Brunner | last post by:
Hi, I have a problem using two ListView controls on one and the same form: Problem: The second ListView is never focused. No matter where I "click" non of the items within the ListView is focused. This is only the matter for the secondly added ListView!!! The first one works perfectly!!
1
2341
by: Rune Jacobsen | last post by:
Hi all, I have an application with one particular form that lists a number of items in a listview. In addition to the listview, there is a panel on top with some simple controls to go back and forth to the next and previous day. Since the number of items in the list can vary from day to day - from zero one day to thirty another, and five the third - my users like the option to have the Window resize itself to exactly fit the number of
9
1658
by: Dimsion | last post by:
Hi, How do i expose all my forms and it controls to other form in the project? I want to be able to add a form and some control on it, this then be available to all other forms. form1 click event: 'this allow me to change the textbox on form2 from form1 Form2.text="" 'this allow me to add item to form2 from form1
1
2376
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i am looking for a way to clear and fill a listview and right after a treeview nearly flicker and delay free. The TreeView and Listview contain Images and about 1000 Items. What can someone recommend me how i can do this, with as less delay and flicker as possible,... What are the right steps and methdods for this. What to do before clearing tree- and listview and what to do while
0
8995
marktang
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...
0
9381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
tracyyun
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...
0
8252
agi2029
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...
0
6078
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();...
0
4608
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...
1
3316
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
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.