c# - Multiple Select but Object reference not set to an instance of an object -


i'm still newbie this.. i'm trying make multiple select in condition if selected rows contains string wanted, i've value, when tried same value in rows, throws object reference not set instance of object, i'm trying is, if i've selected rows need, want clear cells, not remove rows. i'm using right click event, found in case in stackoverflow. hope can understanding, , explanation... here code

if (e.button == mousebuttons.right) {

            rw = dgv_jadwal_sewa.hittest(e.x, e.y).rowindex;               cellvaluenota = (int)dgv_jadwal_sewa.rows[rw].cells[5].value;             string cl = convert.tostring(cellvaluenota);               dgv_jadwal_sewa.rows[rw].selected = true;              contextmenustrip m = new contextmenustrip();              m.items.add("cancel");             m.itemclicked += new toolstripitemclickedeventhandler(m_itemclicked);             m.show(dgv_jadwal_sewa, new point(e.x, e.y));       }       public void cancel_booking()         {                 string cl = convert.tostring(cellvaluenota);                   foreach (datagridviewrow row in dgv_jadwal_sewa.rows)                 {                     if (row.cells[5].value.tostring().tostring().contains(cl))                     {                         rw = row.index;                         //row.selected = true;                         dgv_jadwal_sewa.rows[rw].selected = true;                           break;                     }                 }             } 

it's throw on line (row.cells[5].value.tostring().tostring().contains(cl))

row.cells[5] null or row.cells[5].value null or row null.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -