Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2007

Tip: Looking for answers? Try searching our database.

Inserting rows between existing rows in a list view and List view Flicker

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miesha.James@gmail.com - 04 Apr 2007 14:17 GMT
Hello.

Is there a way you can insert a new row between current rows in a .NET
listview?  I tried and it was no success.  The reason I want to do
this is because when the application starts up it prints a list of
id's in the listview window.  The window has to be updated every
2seconds and I would need to be able to insert the data pertaining to
a certain id under that id.

So far, I havent found a way to acheive this so I'm currently updating
the entire window and reprinting everything.  Unfortunately, this
doesnt allow the user to click on the id and expand the rows and show
the information under the id or to hide the information under the id,
because the id is constantly being updated.

Also, is there a way to stop the flicker in a listview when it is
being updated?

Does anyone have any suggestions?

Thanks.
William DePalo [MVP VC++] - 04 Apr 2007 14:42 GMT
> Is there a way you can insert a new row between current rows in a .NET
> listview?  I tried and it was no success.  The reason I want to do
> this is because when the application starts up it prints a list of
> id's in the listview window.  The window has to be updated every
> 2seconds and I would need to be able to insert the data pertaining to
> a certain id under that id.

I should point out that I'm not at expert at .Net.

That said, in Win32 what you do in a case like yours is to send the listview
control a WM_SETREDRAW message inhibiting repaints, then you make the
changes, then you invalidate the control and finally you send another
WM_SETREDRAW to re-enanle display updates.

A quick google seems to imply that others who have wanted to do this have
P/Invoked the native technique that I sketched:

http://weblogs.asp.net/jdanforth/archive/2004/03/12/88458.aspx

http://www.windowsforms.net/FAQs/default.aspx?PageID=2&ItemID=193&CategoryID=22&
tabindex=3


Regards,
Will
www.ivrforbeginners.com
Ben Voigt - 05 Apr 2007 21:36 GMT
>> Is there a way you can insert a new row between current rows in a .NET
>> listview?  I tried and it was no success.  The reason I want to do
>> this is because when the application starts up it prints a list of
>> id's in the listview window.  The window has to be updated every
>> 2seconds and I would need to be able to insert the data pertaining to
>> a certain id under that id.

ListView has an Items property, which in turn exposes an Insert method.  Is
that what you've tried?  Are you using data binding?  In that case,
implement IBindingList and fire the ListChanged event passing ItemAdded in
the ListChangedEventArgs.

> I should point out that I'm not at expert at .Net.
>
[quoted text clipped - 9 lines]
>
> http://www.windowsforms.net/FAQs/default.aspx?PageID=2&ItemID=193&CategoryID=22&
tabindex=3

The .NET way is SuspendLayout/ResumeLayout, which may or may not be 100%
effective for ListView

> Regards,
> Will
> www.ivrforbeginners.com
Miesha.James@gmail.com - 06 Apr 2007 21:37 GMT
> > <Miesha.Ja...@gmail.com> wrote in message
> >news:1175692661.612840.113390@e65g2000hsc.googlegroups.com...
[quoted text clipped - 32 lines]
>
> - Show quoted text -

I tried to get the index of the row I need to place the new row under
and I tried to insert the row by adding 1 to the index, but I got an
error saying that it already existed.  I'm currently clearing all of
the items out of the list and rewriting them, but I think it adds to
the flicker problem and I can't add an event handler to the id column,
because it's constantly being cleared and rewritten.  I will look into
the data binding.

Will, thanks for the P/Invoke idea.  I haven't implemented it yet, but
I'm currently working on it.

Thanks.
Ben Voigt - 09 Apr 2007 15:33 GMT
> I tried to get the index of the row I need to place the new row under
> and I tried to insert the row by adding 1 to the index, but I got an
[quoted text clipped - 3 lines]
> because it's constantly being cleared and rewritten.  I will look into
> the data binding.

Uh-uh.  Don't look into databinding.  I was just saying, that IF you were
using databinding, would explain why you couldn't insert a row with the
normal method (Insert).

What line of code gave you an error that the row already existed?  Please
indicate the data type of each variable that appears in that line as well.

> Will, thanks for the P/Invoke idea.  I haven't implemented it yet, but
> I'm currently working on it.
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.