C# WPF listView nonSelected Item Edit -


select_listviewupdate ==> complete implementation.

nonselect_listviewupdate ==> not selected, not know how item.

c# formbase listview.item[2].subitems[3].text = "asdf"

c# wpf mainwindows don't know. how to....

be stopped here.

using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; using system.threading;  namespace ex_wpflistview {     /// <summary>     /// mainwindow.xaml     /// </summary>     public partial class mainwindow : window     {         public mainwindow()         {             initializecomponent();             thread servicestatusupdatethread = new thread(new threadstart(updatecycle));             servicestatusupdatethread.start();                }          private void window_loaded(object sender, routedeventargs e)         {             (int = 0; < 10; i++)             {                 listpkt pkt = new listpkt();                 pkt.test_1 = i.tostring();                 pkt.test_2 = (10 - i).tostring();                 pkt.test_3 = i.tostring();                 wpflistview.items.add(pkt);             }         }          private void updatecycle()         {             while (true)             {                 select_listviewupdate();                 nonselect_listviewupdate();                 thread.sleep(500);             }         }          private void select_listviewupdate()         {             listpkt pkt = new listpkt();             dispatcher.invoke(system.windows.threading.dispatcherpriority.normal, new action(delegate             {                 pkt = (listpkt)wpflistview.selecteditem;                 if (pkt != null)                 {                     pkt.test_2 = datetime.now.tostring("hh:mm:ss");                     wpflistview.items.refresh();                 }             }));         }          private void nonselect_listviewupdate()         {             listpkt pkt = new listpkt();             dispatcher.invoke(system.windows.threading.dispatcherpriority.normal, new action(delegate             {                 // listview.items[3].subitems[2].text = "aaaaaa";             }));         }     }      public class listpkt     {         public string test_1 { get; set; }         public string test_2 { get; set; }         public string test_3 { get; set; }     } }   <window x:class="ex_wpflistview.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525" loaded="window_loaded">     <grid>         <stackpanel margin="0,0,0,0">             <listview itemssource="{binding mainscrollview, mode=twoway}" name="wpflistview">                 <listview.view >                     <gridview>                         <gridviewcolumn width="150" header="viewtest1"    displaymemberbinding="{binding test_1}"  />                         <gridviewcolumn width="150" header="viewtest2"   displaymemberbinding="{binding test_2}" />                         <gridviewcolumn width="150" header="viewtest3"   displaymemberbinding="{binding test_3}" />                     </gridview>                 </listview.view>             </listview>         </stackpanel>     </grid> </window> 

i think use code :

{     {         ((listpkt)wpflistview.items(wpflistview.items.indexof(r))).test_1 = "something";      }     wpflistview.items.refresh(); } 

where r item want edit

i hope helps

i vb programmer , code snippet got converting code vb c#

my original code goes :

r = ctype(txtqty.tag, ultimatestoredataset.itemsbonusesrow)                 ctype(lvitemsbonuses.items(lvitemsbonuses.items.indexof(r)), ultimatestoredataset.itemsbonusesrow)                     .basequantity = cint(txtqty.text)                     .bonusquantity = cint(txtbonus.text)                 end                 lvitemsbonuses.items.refresh() 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -