vb.net - Clear and Add items to a DataGridViewComboBox but only for the selected row, not the entire column -
there couple of posts on datagridviewcombobox
don't cover specific case. have dgv in shoe billing form, , first 3 columns comboboxes. first, model; second, color; third, number. since want people sell what's in stock, in cellvaluechanged
; depending on columnindex
clear next combo , insert corresponding items. quick example, have "nike pegassus" in first combo, select "green" on second one, , select available numbers model , color , insert third column, after cleared items in there, in case there color selected. here's part of code
if e.rowindex >= 0 if e.columnindex = 0 dim objcolumna datagridviewcomboboxcolumn = dtgdetalle.columns(1) dim colitems new collection dim dattabla datatable dim objcolor new clscolor(objobjeto.sesion) dattabla = objcolor.buscartodos("codcolor in (select distinct stock.codcolor stock inner join color on stock.codcolor = color.codcolor stock.cantidad > 0 , stock.codmodelo=" & ctype(objcolumna.items(dtgdetalle.rows(e.rowindex).cells(0).value), clselementolistafactura).codigo & ")") objcolor = nothing objcolumna = dtgdetalle.columns(1) objcolumna.items.clear() dtgdetalle.rows(e.rowindex).cells(1).value = nothing dtgdetalle.rows(e.rowindex).cells(2).value = nothing each darrecord in dattabla.rows objcolor = new clscolor(objobjeto.sesion) objcolor.codigo = darrecord.item("codcolor").tostring dim objelemento new clselementolistafactura(darrecord.item("color").tostring, objcolumna.items.count, "c", cint(darrecord.item("codcolor").tostring), "1") objcolumna.items.add(objelemento) objcolor = nothing next objcolumna.valuemember = "itemdata" objcolumna.displaymember = "name" . . . . . .
that works fine 1 row! when go row #2 , change index of first combo, want combos (1, 1) , (1, 2) altered, (0, 1) , (0, 2) cleared , new values inserted. best way me clear items of specific row within column, , insert items in cell? if i'm not being clear, please ask. starting become pain. thanks!
Comments
Post a Comment