Nov 7, 2009

code to make an editable listview item for vb.net - VB.NET: Problem With Listview Controls

free web hosting
Open Discussion & Free Web Hosting > Astahost > Asta ANSWERS!

code to make an editable listview item for vb.net - VB.NET: Problem With Listview Controls

(G)Arnold
code to make an editable listview item for vb.net
VB.NET: Problem With Listview Controls

Please give me some code on how to make a listivew item which index is 4 to be editable..

question by Arnold


Keywords:

Comment/Reply (w/o sign-up)

tansqrx
It looks like the original poster was naughty and got himself banned. Anyway here is a solution for anyone else who needs it.

Setup
•Create new project called EditListviewExample in Visual basic 2008
•Add listview called lvMain
•Add Item1, Item2, Item3, Item4, and Item5 as Items using the design view
•Change View to list
•Add a button named btnGet, numericupdown named nudGet, and a textbox named txtGet
•Add a button named btnPut, numericupdown named nudPut, and a textbox named txtPut
•Add Option Strict On and Option Explicit On to the code

CODE
Option Strict On
Option Explicit On

Public Class frmMain

    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
        'This is to check and see if the index provided by nudGet is a valid index, otherwise
        'and exception will be thrown.
        If CInt(nudGet.Value) < lvMain.Items.Count Then
            'the values of a listview is held in the .items property
            txtGet.Text = lvMain.Items(CInt(nudGet.Value)).Text
        Else
            MessageBox.Show("Selection falls outside of the bounds of the listview")
        End If
    End Sub

    Private Sub btnPut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPut.Click
        'This is to check and see if the index provided by nudPut is a valid index, otherwise
        'and exception will be thrown.
        If CInt(nudPut.Value) < lvMain.Items.Count Then
            lvMain.Items(CInt(nudPut.Value)).Text = txtPut.Text
        Else
            MessageBox.Show("Selection falls outside of the bounds of the listview")
        End If
    End Sub
End Class


The way to access any value within a listview is to access the item() property of the listview. This example will get the item value specified by the numericupdown or conversely put a value in the select item. You must realize that a listview is zero based like most other .NET controls and structures. If you get the value from the first slot you should ask for item(0).

The listview is an incredible powerful control and you can do some very amazing things with it. You can also get the highlighted item by using selecteditems() or get the item under the mouse by using getimageat().

 

 

 


Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Code Editable Listview Item Vbnet Vbnet Listview Controls


    Looking for code, to, make, an, editable, listview, item, for, vb.net

See Also,

*SIMILAR VIDEOS*
Searching Video's for code, to, make, an, editable, listview, item, for, vb.net
advertisement



code to make an editable listview item for vb.net - VB.NET: Problem With Listview Controls

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com