On Apr 5, 4:36 pm, "Ben Voigt" <r...@nospam.nospamwrote:
"William DePalo [MVP VC++]" <willd.no.s...@mvps.orgwrote in messagenews:uM****************@TK2MSFTNGP02.phx.gb l...
<Miesha.Ja...@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
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 alistof
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.
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/arc.../12/88458.aspx
http://www.windowsforms.net/FAQs/def...ItemID=193&Cat...
The .NETway is SuspendLayout/ResumeLayout, which may or may not be 100%
effective for ListView
Regards,
Will
www.ivrforbeginners.com- Hide quoted text -
- 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.