c# - How to prevent a listview from adding a blank line? -


currently code.

        textreader reader = new stringreader(richtextbox1.text);         string[] stritems = null;         while (reader.peek() != -1)         {             string nextrow = reader.readline();             if (!listview1.items.containskey(nextrow.gethashcode().tostring()))             {                 listviewitem item = new listviewitem();                 item.name = nextrow.gethashcode().tostring();                 stritems = nextrow.split("-".tochararray());                 item.text = stritems[0].tostring();                 try                 {                     item.subitems.add(stritems[1].tostring());                 }                 catch (exception)                 {                 }                 try                 {                     item.subitems.add(stritems[2].tostring());                 }                 catch (exception)                 {                 }                 try                 {                     item.subitems.add(stritems[3].tostring());                 }                 catch (exception)                 {                 }                 try                 {                     item.subitems.add(stritems[4].tostring());                 }                 catch (exception)                 {                 }                 listview1.items.add(item);             }         } 

it add's items textbox listview, if there blank line in textbox adds blank item listview. looking way stop happening. appreciated.

add if check that:

if(!string.isnullorempty(nextrow)) {    execute code need } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -