Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Clear The Contents Of A ListView

I have created a form that uses ListView in Report format. How do I clear the contents of the listview so that I can update the data? Right now all I can get it to do is append to the end of the list, thus repeating most of the data.

In a standard listbox, you would just use:


Is there something similar for ListView that I'm just not seeing?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
can any one provide sample code on how to clear the contents of a listview.
thanx in advance.
george .

ComboBox Clear Contents?
How can I clear the contents of a combobox, if its a control of a commandbar:


I already populate it, but I wanna refresh it, how can I clear all the items?

Thanks for any reply

How To Clear Form Of Contents
I have 5 checkboxes, I've already set it so if one is unticked then all its data will reset, but I want to have a command button that will clear the form,

In other words the command button will make all checkboxes unticked or reset

Clear Datagrid Contents ...
Dear Friends,

How can I clear the contents of a datagrid?


How To Clear The Contents Of WebBrowsercontrol In VB

I have a page loaded already in the WBC control. when i click on an command button, i post another URL, before that the contents of the previous page has to be cleared , and then the new page has to be loaded.

When the new page loads th eold one get stays there.

I tried using about:blank it doesnt work

Since Iam using a low bandwidth Internet connectivity i want to do this

Thankx in advance

Clear Contents Of A File
i have created a .log file within in my application so i can see what the app is getting up to. how can i clear the conetents of the file from with in vba. i have been using the file system object but cant find a way of deleting the conetenst the the file file that i have created and added text to.

any help would be appreciated.

thankx in advance

Clear Datagrid Contents ..Help
i use vb6 with ado and Database as access2002 .. with below code i have set the data grid data source to
display all records of CONTRDETAIL Table.

Now in the form load i dont want the datagrid to dispaly any records. so that with addnew i can add a record easily without displaying the earlier records in the datagrid .. How can it be possible ..
Can anyone Help .. Plssssssssssssssssss. with some suggesstion

Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=TEST"

Set RS = New ADODB.Recordset
With RS
.ActiveConnection = cn
.LockType = adLockOptimistic
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.Source = QUERY
End With

Set DataGrid1.DataSource = RS

End Sub

Thanks in anticipation

Clear Combo Box Contents

I am new to vb and access and have hit a problem trying to clear the contents of the combo boxes on a search form.

I have searched vbCity and have tried the suggested code but I cannot get it to work.

I have a search form which contains 8 combo boxes and 3 check boxes and have added a command button to clear the contents of the form.

I have tried the following code which comes up with Complie Error : Method or data member not found (for .Left)

Code:Private Sub clrr_Click()
  With Forms.Add(Form_frmsearchquery2.Name)
.Move Form_frmsearchquery2.Left, Form_frmsearchquery2.Top, Form_frmsearchquery2.Width, Form_frmsearchquery2.Height
    End With
    Unload Form_frmsearchquery2
End Sub

I have also tried the code below which comes up with the same Complie Error : Method or data member not found (for .Clear)

Code: Private Sub clrr_Click()
End Sub

I would be grateful for any help



What Is The Query To Clear Contents Of SQL DB?
what is the query to clear contents of SQL DB?

Clear Contents Of A Text File
Is there a way to clear the contents of a text file via VB 6.0 code? I am currently deleting the file (kill) and opening a new file with the same name. What I would like to do is open the file, give a "Clear" command, then refill the file. Thanks in advance!

How To Clear The Contents Of A Text File?
How can I clear the contents of a text file? I have a text file that gets autopopulated with information coming from another application, and Im reading that file from within my VB6 application. However, after a while,. the file gets large, and the reading gets slower. I want to be able to clear teh contents of the file after reading it. I dont want to kill the file. Any suggestions?


Clear Contents Of A Block Of Cells In VB6
I have to clear the contents of a range of cells (in Excel), in this example from D7 thru D67. For some reason I can't hit the right combination to make the command work. Either get a syntax error or not supportable errror. All I want to do is get the range and clear the contents of all cells selected. Any help?

Thanks in advance.

NR = 2

On the above, don't know why the smiley face took the place of the colon and the D in front of 67, should read "D7 colon D67"

How Do I Clear The Contents Of A Textbox And Update It ?
Hello again all,

Every aspect of my program works great except one thing.

I call a form (rbt_ack_frm) with two textboxes on it, these boxes
are populated based on reading from two files (they are
essentially verification boxes).

The first time you go through the data is perfect but, if
you "cancel" the operation and go back to form1 and choose
additional options and then go back to this form the old values
are still in the box. The files that these boxes get their data from
are correct but these two textboxes never update.

Here's the code for the entire form

VB Code:
Private Sub cxl_rbt_combtn_Click()    rbt_ack_frm.Hide        Open "C:
bt_imd.txt" For Input As 1    'clear file if "cancel"    Print 1, ""        Close 1        Open "c:
bt_wat.txt" For Input As 2    'clear file if "cancel"    Print 2, ""    Close 2        Form1.Show    End Sub Private Sub Form_Load() 'Heres my problem, I need this to clear before going onto the'next sub, or at a minimum when going to "popsrvlst" it should'write the new values      Call popsrvlst    End SubSub popsrvlst()    Open "c:
bt_imd.txt" For Input As 1    'open rebt_imd file and'populate srvlist1_txt with contentssrvlst1_txt = Input(LOF(1), 1)Close 1     Open "c:
bt_wat.txt" For Input As 2    'open rebt_wat file and'populate srvlist2_txt with contentssrvlst2_txt = Input(LOF(2), 2)Close 2End SubPrivate Sub rbt_ack_combtn_Click()    Open "c:Rebootmgr.log" For Append As 3 'Append to log file'with time of reboot and servers rebooted    Print #3, Now    Print #3, srvlst1_txt    Print #3, srvlst2_txt    Close 3                Shell "C:dly_rbt.bat"                  'Call reboot script and hide 'acknowledge form    rbt_ack_frm.Hide    Form1.ShowEnd Sub  Private Sub Text1_Change() End Sub

Any idea's ? I'd prefer not to create a control array with these
two boxes but if neccesary I will.



Event For Cell On Clear Contents (with Delete Key)
Hello all,

I have code working for my cells when they are changed:

Sub DidCellsChange()
Dim KeyCells As String
KeyCells = "D:D" ' Define which cells should trigger the KeyCellsChanged macro.

If Not Application.Intersect(ActiveCell, Range(KeyCells)) Is Nothing Then ' If the Activecell is one of the key cells
End If

End Sub

Sub KeyCellsChanged()
'My code for change event
End Sub
But this does not fire when I clear the contents of the cell. Is there another event that I should be using?


Can I Clear The Whole Combobox In One Go? Eg Not Knowing Number Of Contents
can i clear the whole combobox in one go? eg not knowing number of contents

How Do I Clear Text Boxes And Change Contents
ok i have 6 text boxes what i am trying to do is clear 4 and move the contents of 1 box to another
the boxes are
Name leave this one
Quantity fill with total box value
Fill clear this one
Dose clear this one
Refill clear this one
Total clear this one
Current change from Yes to No
with this cmd button

Private Sub Command4_Click()
txtQuantity.text=" "
txtFill.text=" "
but this didnt work
If vbYes = MsgBox("Add the new values to the database?", vbYesNo + vbQuestion, "Approval to Add") Then
End If
Unload Me
End Sub


How To Clear Contents Of The Combo Box List At Run Time?
Myname is, as u already know, Nikhil. I am resident of Bangalore In India. I am working on VB 6.0, and I am facing some problem with Combo box handling. PLease help me If you can. My problem is:
How should I clear the contents of a combo box list at run time?

I am adding some items to the combo Box at run time through "Combo1.additem" syntax. Now How should I clear the combo box list contents to add fresh data?

Waiting for ur reply. You can mail me at

Thank You

How To Clear Contents Of The Combo Box List At Run Time?
Dear Readers,
Myname is, Nikhil. I am working on VB 6.0, and I am facing some problem with Combo box handling. Please help me If you can. My problem is:
How should I clear the contents of a combo box list at run time?

I am adding some items to the combo Box at run time through "Combo1.additem" syntax. Now How should I clear the combo box list contents to add fresh data?

Waiting for ur reply. You can mail me at

Thank You

I'm A New At VB Need Help How To Assign A Button To Clear Textbox Contents?

I need help with VB6 on how to assign code to a button (Clear Button) to clear out any numbers that are in my textboxes to allow the user to hit the button and clear out any information within the textboxes. This is a calculator program to convert liters into gallon and pints conversion. I have 3 textboxes (one textbox to allow user to enter the number of liters, the next 2 textboxes the user will not enter anything because these textboxes with display the results of the conversion user will not be able to enter anything within these textboxes), then 3 buttons(the first button allows the users to hit the button to calculate or process the entry, the other is to quit the program and the one I need help with it the button to clear all three textboxes I call it the reset button)

Dim FirstNum, SecondNum, ThirdNum, Button3Compute_Click(), Button3Reset_Click(), ready, display

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Assign text box values to variables
        FirstNum = TextBox1.Text
        SecondNum = TextBox2.Text
        ThirdNum = TextBox3.Text

        'Determine checked button and calculate
        TextBox2.Text = FirstNum * (0.2642)
        TextBox3.Text = FirstNum * (2.1134)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ready > 0 Then
            display.Caption = display.Caption + "0"
            display.Caption = "0"
            ready = ready + 1
        End If
    End Sub
End Class

Please let me know ASAP.



How To Clear And Re-initialize The Contents Of Masked Edit Box
This thread is a follow up to the prior thread "Unable to bind field or Data Member" but of a slightly different topic now. Now inside the thread, we have encountered another related problem that is how to clear the contents of the
masked edit box,that includes the text,format and the mask . After that , we will re-initialize the text,format and mask. The format and mask can be the same.

Details of the problem is at this URL:

Clear Contents Of Combobox In Multipage User Form
I would like to have a command button on a multipage, that when clicked, it would clear the contents of the comboboxes and text boxes on that page.

Thanks for any input everyone

Looping Through A Listview And Adding Contents From One Listview To Another
i have my code for my old listbox but i need to convert it to the listview

any help?

For i = 0 To frmmain.lstQY_IT_DES.ListCount
lstprint.AddItem frmmain.lstQY_IT_DES.List(i)
Next i

Listview Clear
How do you clear the contents of a listview?

Clear A Listview?
I want to delete row in a listview..i thought this would work:

For Each itm In ListView1.ListItems
ListView1.ListItems.Remove ListView1.ListItems.Count - 1

but it gives me "Controls collection has been modified"

what should i do?--btw this is during runtime

How To Clear A Listview
trying to find some kind of listview clear command.

I need to update the contenst of a listview, if i just repopulate it with the new data, it just paces it under the origional data.

how do you clear the contents of a listview?

Clear A Listview.
I have a listview in report mode. how do I clear all the items out of it? Thanks.

Clear ListView
I am loading my ListView with ColumnHeaders. When the user performs a certain action, I would like to clear the ListView (including the ColumnHeaders). Currently I am doing this as follows:


The only problem is that when the ListView is cleared, the grey bar at the top of the control remains grey. I would like it to be made white so as the ListView would simply be a solid white box as opposed to a white box with a grey bar at the top of it.

Seems like this should be easy enough. thx

Clear ListView
How do I clear a ListView control from all of its items?
I always get confused with that control ...

Clear Listview
this is probably really simple, but how do I clear out a listview? I fill it with elements, go off to another screen which changes the number of elements, then I come back and want to reload the listview. But I don't want the original list in there. I need like a Listview.Clear method or something.

How Do You Clear A Listview?
How do you clear a listview. I thought there was an event that did this.

Clear Listview
Is there a clear for a listview. a listbox I use List1.Clear

How do I clear a listview after I delete
a record from the db.
I know how to delete I just need to know how to refresh the listview...refresh just loads another mbd listing on top of the existing one.


How To Clear A Listview
I have loaded up a recordset into a listview, but now im trying to sort the columns, and i get a 2nd full set of data,
im looking for a way to clear out the data in the listview and then repull the data,
i have tried recordset.delete, but was getting errors, not really sure i want to do that anyways....

VBA - Access - Clear Listview
Does anyone know how to clear a listview in VBA?
I have tried listview.listitems.clear but that doesn't work.

Clear Highlighted In The Listview
How I can clear the highlighted color in the listview?

It highligted the row in the listview during form load. How to clear this?

Listview Clear Function
I want to clear al the listview.
listview1.clear does not work.
can someone give me the code to do this?

Clear ListView Control
Hi There,

Just wondering how I would go about clearing the listview control

I need the same as List1.Clear for listview

Clear A Column In Listview ?
can you clear an individual column on a listview and / or a subitem column ?

Clear A ListView FAST

Is there any way of clearing a list view really fast
at the present i am using listview.listitems.clear
which when there are several thousand items can take some time to clear.

any ideas on how to clear these quickly

thank you in advance


How Do You Clear All The Data In The ListView To Nothing?
How do you clear all the data in the ListView to nothing? I mean,
clear it like the Clear method in the ListBox control...anyone

How Do You Clear A ListView Control?
How do You Clear a ListView Control?

Thanks in advance!

Command To Clear A Listview Table?
I want to refresh a listview so how do I clear a listview so I can reinput all the info in the order I want

Dynamically Clear /alter The ListView Control
I need help with the ListView Control. using the listView control within an Access 97 application. I am trying to dynamically add and remove items from a listview control. I am wonderin if there is an easy way to clear the control without having to delete each item in the ListItems collection.

Transfer Listview Contents
How would I copy the listview items from one to another? for instance

listview1.listitems(2) = frmmain.listview3.listitems(2)


Printing Listview Contents?
how do you do that?

Printer.Print frmDetails.ListView1.text<---its not .text? so what?

also same question regarding a listbox? listbox1.??


Clearing Contents Of Listview
This sounds incredibly simple but I can't work out how to completely clear the contents of a listview, I can clear the column headers but not the actual content?

Much appreciated If anyone can help


Printing Listview Contents?
Hi, how would I print the contents of a Listview that is using the report format?



Create PDF From Listview Contents
Hi, I found many threads where people ask how to create a PDF file. In a lot of those threads people are pointed to this code.

Generally it works fine, but every line or word needs to be positioned separately, but sometimes more than a 1000 rows (6 columns) need to be "written". Does anybody have any idea how to create a PDF from the contents of a Listview and keep everything in the right position, without having to position 6000 items manually? I'm absolutely clueless.

Saving Listview Contents
How would i go about saving a listview's contents for 8 columns and around 150 rows to .INI file? HELP PLEASE!

Copyright 2005-08, All rights reserved