When I call the clear method for a ListView object, the column headers disappear - VB.Net - vb.net

Good day, I've just started teaching myself VB.net. I'm trying to create a simple note keeping program.
I've come across a problem, where by I call the Clear method of the ListView object, and its column headers disappear.
screen shot of what happens
The code for button 2 is:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
lstNotes.Clear()
End Sub
Any help will be appreciated, thanks!

The Clear method on a listview does exactly that. Just as advertised.
Use lstNotes.Items.Clear() instead.

Augh, as luck would have it, I got the answer Just after posting.
lstNotes.Items.Clear()

use Items.clear() instead!
lstNotes.Items.Clear()

Related

Delete selected row in Datagridview

I have a datagridview in which I want to insert a button for removing the selected row. I created without any problems the AddRow Button and, following the same idea, I tried to create the RemoveRow button with the following code:
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
DataGridView2.Rows.Remove()
End Sub
When I start debugging I'm having BC30455 error, about not specified argument. What am I doing wrong? I tried to find out here in the forum but I've found only sth about C# and not VB.net
Best regards and thanks all are gonna answer me.

How should I reset my application using vb2008 except for the last form?

So, I made an application which composes several forms. It contains saving scores at the end of the game(form). However, when I try to reset the game, it resets all the data with this code:
Private Sub ResetDataToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetDataToolStripMenuItem.Click
Application.Restart()
Me.Refresh()
I only want to reset all forms except for the scoretable form which is the last form. Can you give me the easiest way to solve my problem?
P.S I am a newbie for this. Please help me guys. This will serve as my quarterly exam. I need to pass.

vb.net connects to database access

im really new to this language so this is so simple please answer
Me.InfoBindingSource.RemoveCurrent()
i only have id t on my delete button do i have to adsome codes? knows anyone?
i've searched some sites and it is the only code they say. i connected it and actually worked on add. but with delete it dont.
Do i need to move something.. like files?
i've tried everything this is my last hope. thanks for the answer :)
here is the whole code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.InfoBindingSource.RemoveCurrent()
End Sub
That RemoveCurrent method will mark the current row in the bound DataTable as Deleted. Just like when adding or editing rows though, you still have to call Update on your data adapter or table adapter to save that change back to the database.

Sorting unbound datagridview programmatically

I need to sort the datagridview programmatically. I googled a lot but nothing worked for me.
Datagridview is not bound to any datasource. Data is being added manually.
My requirement is to sort it as when a 'Sort' button is pressed.
Can anyone suggest me code in vb.net?
Try like this
DataGridView1.Columns(0) -> Give which column you want to sort
System.ComponentModel.ListSortDirection.Ascending -> Give direction of ascending or decending
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DataGridView1.Sort(DataGridView1.Columns(0),
System.ComponentModel.ListSortDirection.Ascending)
End Sub
The code above works. You can, of course, choose any valid column. Here it is in C#, the only difference is the square braces []:
gridview.Sort( gridview.Columns[0], System.ComponentModel.ListSortDirection.Ascending );

How to update value in combo box using combo box text?

I have a very simple question that i can't seem to find the answer, i have looked up and down in google, msdn with no luck...
it's really simple yet i can't seem to wrap my mind around it.
here goes:
If i'm using simple Drop down style combo box(the one that looks like a listbox with textbox attached on top of the cbobx control) when i want to update one of the value in it, once i start typing in the textbox the selection inside the combo box is gone. Thus i can't update the value inside the combo box.
i know i can use a regular text box to do this, but i'd really like to make this work or i would really loose sleep over this.
Thanks in advance for all your help.
Ray
It doesnt seem very intuative editing the selection in a combobox, but the following should do the trick:
Private cbindex As Integer
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cbindex = ComboBox1.SelectedIndex
End Sub
Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus
ComboBox1.Items(cbindex) = ComboBox1.Text
End Sub