public class mydatagridclass inherits datagrid private m as new arraylist
public readonly property multiselectedindex() as integer() get return m.toarray(gettype(integer)) end get end property
protected overrides sub onmousedown(byval e as system.windows.forms.mouseeventargs) debug.writeline("datagrid has hit") dim posdg as point = new point(e.x, e.y) dim hitdg as datagrid.hittestinfo = hittest(posdg) if hitdatagrid(hitdg) then mybase.onmousedown(e) debug.writeline("mousedown has gogogo.....") end if end sub
private function hitdatagrid(byval hit as datagrid.hittestinfo) as boolean try select case me.modifierkeys case keys.control if hit.row > -1 then if m.indexof(hit.row) > -1 then m.remove(hit.row) me.unselect(hit.row) else m.add(hit.row) me.select(hit.row) end if end if return false case keys.shift if hit.row > -1 then for each indexold as integer in m me.unselect(indexold) next m.clear() dim i, intstep as integer if hit.row > me.currentrowindex then intstep = 1 else intstep = -1 end if for i = me.currentrowindex to hit.row step intstep m.add(i) me.select(i) next end if return false case else for each index as integer in m me.unselect(index) next m.clear() if hit.type = datagrid.hittesttype.rowheader then m.add(hit.row) end if return true end select catch ex as exception debug.writeline(ex.tostring) end try end function end class