Deleting a DataGrid row ?!
-
hi coders, i'm perplexed with VB .NET DataGrid... i can't find out how it is possible to remove a selected row from that control. imagine we have a button "suppress a line" and the DataGrid from which the user is able to select a row. what i want is when the button is clicked, i'd like to suppress the selected item from the DGrid... does anyone know how to do that ? thanx in advance
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
hi coders, i'm perplexed with VB .NET DataGrid... i can't find out how it is possible to remove a selected row from that control. imagine we have a button "suppress a line" and the DataGrid from which the user is able to select a row. what i want is when the button is clicked, i'd like to suppress the selected item from the DGrid... does anyone know how to do that ? thanx in advance
TOXCCT >>> GEII power
[toxcct][VisualCalc]Hi, You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. eg: dim dtable as new datatable dtable = grid.datasource. dtable.rows.removeat(index) (Use some logic here to pass the row no. i.e. the index) reassign the table. grid.datasource = dtable. do let me know if this helps.
-
Hi, You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. eg: dim dtable as new datatable dtable = grid.datasource. dtable.rows.removeat(index) (Use some logic here to pass the row no. i.e. the index) reassign the table. grid.datasource = dtable. do let me know if this helps.
genius123 wrote: You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. yes, of course, but i didn't know how to catch the index of the selected lineto delete the associated item in my ArrayList... so, thank you for your answer ;)
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
genius123 wrote: You cannot directly delete/suppress a row from a datagrid. You have to manipulat its datasource and then reassign the datasource. yes, of course, but i didn't know how to catch the index of the selected lineto delete the associated item in my ArrayList... so, thank you for your answer ;)
TOXCCT >>> GEII power
[toxcct][VisualCalc]Catching the rowindex is pretty easy. index = datagrid.currentrowindex() if ur using a dataset, delete the row using ds.Tables("tablename").Rows.RemoveAt(index) or a datatable then dtable.rows.removeat(index) and plz try elaborating problems a bit to get exact answers ;)