Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Photo
- - - - -

VB.NET: Problem With Listview Controls


7 replies to this topic

#1 vhortex

vhortex

    Guilty Until Proven Innocent

  • Members
  • 513 posts

Posted 12 November 2005 - 01:25 PM

Hello, I am kinda new to Vb.net and I need some help regarding listview.

I want to add a certain value at a certain location for a listview. Like adding a new row at the current selected area.

What the program do as of now was to add new rows at location 0.

can anyone help me..

thanks..

Edited by microscopic^earthling, 13 November 2005 - 08:08 AM.


#2 miCRoSCoPiC^eaRthLinG

miCRoSCoPiC^eaRthLinG

    PsYcheDeLiC dR3aMeR

  • [MODERATOR]
  • 2,248 posts
  • Gender:Male
  • Location:Bangkok, Thailand
  • Interests:Photography, Magic Tricks, Numismatics & Philately to some extent, Being a nuisance in general (that's my favourite)
  • myCENTs:NEGATIVE[-21.50]

Posted 13 November 2005 - 04:11 AM

Hello, I am kinda new to Vb.net and I need some help regarding listview.

I want to add a certain value at a certain location for a listview. Like adding a new row at the current selected area.

What the program do as of now was to add new rows at location 0.

can anyone help me..

thanks..

View Post



What do you mean by new row at the currently selected area ? Can you be a little more clear on that ?

ListView object won't add rows at location 0, as far as I know. Instead it would put it at the bottom.

If you mean that you want to add a row ABOVE or BELOW a single or a set of items in the listview, then you can take the following approach:

For a ListView you can set it's property MultiSelect to true. If so, an user might select a single row or multiple rows at a time. If set to false a user ca select only a SINGLE line.

Say, I want to insert a row below a selected row.
There's a method called SelectedIndices() under ListView class which returns an array containing the Index of the selected items in the list. The index of the first item is ZERO.

Now in case MultiSelect is set to false - SelectedIndices will return only a single row, but when MultiSelect is true, this will return an array.

If false, we can get the selected row (lets say, Max) by simply looking for it's index in the SelectedIndices() array's position ZERO - why we can be sure that this item will be in position ZERO is - that this array will containing ONLY ONE item, based on MultiSelect to be false.
So two cases:

Case 1: MultiSelect = false
Dim Max as Integer = lsvReceipts.SelectedIndices.Item (0)

OR,

Case 2: MultiSelect = true
If not, from that array you have to determine the highest index of the SelectedItems, to know which position you've to insert this new value.
Lets use a short example with this list of receipts ( lsvReceipts ):
            'We start by creating a variable called Max and store the first index in
            'SelectedIndices Array.
            Dim Max As Integer = lsvReceipts.SelectedIndices.Item(0)

            'We go through the SelectedIndices Array and find the highest index stored in it.
            'We loop through 0 to SelectedIndices.Count - 1, as we're counting from '0' .
            For Counter = 0 To lsvReceipts.SelectedIndices.Count - 1

                'Check with the item in each position - see if it's greater than Max
                If Max < lsvReceipts.SelectedIndices.Item(Counter) Then

                    'Set Max equal to it
                    Max = lsvReceipts.SelectedIndices.Item(Counter)

                End If

            Next

            'Now we know the Index of the Last Selected Item ( stored in Max )


So armed with the last selected item's position, we ADD a '1' to it, since what we want to insert, goes at a position below it. So
'Increase Max by '1'
Max += 1

Now, simply issue an insert statement:
'Insert new item at that position.
lsvReceipts.Items.Insert ( Max, "New Item" )

There you go... ;)

#3 vhortex

vhortex

    Guilty Until Proven Innocent

  • Members
  • 513 posts

Posted 13 November 2005 - 08:34 AM

Oh, I am sorry, this should go to the VB.net portion.

I am going to edit the post and topic until I found out someone have mess with the proxy server and block the word listview.

here is the more detailed problem.


I have a listview in vb.net. The purpose of the listview is to display data to the screen which is fetch from a mySQL database.

The listview needs an Insert function where the purpose of the insert is to add a new row in the listview at the exact location where the user clicks [selected item] and move the rows displayed 1 line below down by 1 row.

this is a crude example of the code that I am facing
LVI = uiListViewSData.Items(0)
        indx = uiListViewSData.SelectedItems(0).Index 

        uiListViewSData.Items().Insert((indx + 1), "")

I guess that the problem is with VB.net, for some reason the same code now runs.

There is no modification whatsoever..

Can you kindly move this topic to vb.net section for there are more people who may need this answer.

#4 miCRoSCoPiC^eaRthLinG

miCRoSCoPiC^eaRthLinG

    PsYcheDeLiC dR3aMeR

  • [MODERATOR]
  • 2,248 posts
  • Gender:Male
  • Location:Bangkok, Thailand
  • Interests:Photography, Magic Tricks, Numismatics & Philately to some extent, Being a nuisance in general (that's my favourite)
  • myCENTs:NEGATIVE[-21.50]

Posted 13 November 2005 - 08:44 AM

this is a crude example of the code that I am facing

LVI = uiListViewSData.Items(0)
        indx = uiListViewSData.SelectedItems(0).Index 

        uiListViewSData.Items().Insert((indx + 1), "")

I guess that the problem is with VB.net, for some reason the same code now runs.

There is no modification whatsoever..

View Post


First - read the first post I made on this thread.

Now, your command, indx = uiListViewSData.SelectedItems(0).Index - fetches you the index of SelectedItems(0) - which should be okay, but sometimes I've had problems with the SelectedItems method - so I resort to using SelectedIndices() instead. See for yourself in this case, uiListViewSData.SelectedItems(0).Index is returning '0' as an index to your SelectedItems(0). Hence, quite obviously, your data WILL get added to the ZERO-eth position.

Since you're choosing just one row at a time, set MultiSelect of ListView to false and then use,
indx = uiListViewSData.SelectedIndices(0)
to fetch the selected row correctly.

Insertion is exactly what you're come up with:
uiListViewSData.Items().Insert((indx + 1), "New Item....")

#5 vhortex

vhortex

    Guilty Until Proven Innocent

  • Members
  • 513 posts

Posted 13 November 2005 - 10:37 AM

I think you have mis-interpreted my post, anway the index stuff returns non zero because the requirements is that you must click the row first..

I used to use msgbox() to see what the returned value was.

---

it is working now without any modification..

my next question is if you still have time..

are there any method to make the listview editable by clicking a certain column and row in the listview?

---

about the indices i have coded a newer one with the indices that you have recommended but i have not yet rebuild the project .

#6 miCRoSCoPiC^eaRthLinG

miCRoSCoPiC^eaRthLinG

    PsYcheDeLiC dR3aMeR

  • [MODERATOR]
  • 2,248 posts
  • Gender:Male
  • Location:Bangkok, Thailand
  • Interests:Photography, Magic Tricks, Numismatics & Philately to some extent, Being a nuisance in general (that's my favourite)
  • myCENTs:NEGATIVE[-21.50]

Posted 14 November 2005 - 02:41 PM

my next question is if you still have time..

are there any method to make the listview editable by clicking a certain column and row in the listview?

---

View Post


Hehe.. I've used so much of listview during past two months, I could write a walkthrough blindfolder...

Anyways, basically there are 2 controls in VS.NET that can produce similar LIST outputs:
1. ListView
2. Datagrid

Both have advantages and disadvantages. Datagrid is way more complex but immensely powerful. ListView far easier (and works faster) - but limited in features.

With DataGrid, you can easily achieve what you want to do - EDIT any particular COLUMN in a ROW.

With ListView, unfortunately - you can edit ONLY the FIRST column of each ROW - which itself is an ITEM (which you add to the ListView)... all other columns associated with this ITEM are SUBITEMS, which are NON-EDITABLE. Anyways, to go ahead and edit only the first item, you've to set the ListView property called LabelEdit to TRUE.

In case you want to do the same with DataGrid (but be able to edit ALL) - let me know. I can help you out there too.

Regards,
m^e

#7 Guest_(G)Norbs_*

Guest_(G)Norbs_*
  • Guests

Posted 12 December 2009 - 09:28 AM

LISTVIEW PROBLEM.VB.NET: Problem With Listview Controls

 Hi. I have a problem regarding listview control in asp.Net and vb.Net. I'm developing a web based application wherein the user will search for a topic and the search results will be displayed and bind  in a listview. There's a link in a listview where users can click to view a file.

I want to get the selected value of each item in a listview after the user click the link.

Anyone knows how to do it?

Thanks..

You can email me here: norbs_27@yahoo.Com

Thanks a lot and godbless!

-reply by Norbs

 



#8 Guest_(G)ct kd_*

Guest_(G)ct kd_*
  • Guests

Posted 22 February 2010 - 02:13 AM

wpf listview backcolor as tranparentVB.NET: Problem With Listview Controls

hi all,

I have a problem to set the listview backcolor as transparent. I already tried but still cannot work. I use vb.Net languange WPF. Anyone can help me?? Thanks in advance.

You can reply here or to my email - choc.Creezy@gmail.Com

-reply by ct kd



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users