Hello guys,
I want to delete a particular row which is selected in the datagrid(ie datagrid.text row will be delete)....
How to do? Advance thanks :)
Printable View
Hello guys,
I want to delete a particular row which is selected in the datagrid(ie datagrid.text row will be delete)....
How to do? Advance thanks :)
Try this:
Code:Private Sub Command4_Click()
If MsgBox("Are you sure", vbQuestion + vbYesNo, "Confirm Delete") = vbYes Then
Adodc1.Recordset.Delete adAffectCurrent
Adodc1.Recordset.Requery
Adodc1.Refresh
DataGrid1.Refresh
End If
End Sub
In other words, don't delete the record from the grid. Delete it from the underlaying datasource, i.e., your database, and then refresh the grid.
... or better yet don't use any databound controls at all and no data control either. :)Quote:
Originally Posted by Hack
MsFlexgrid and ADO library can be much more better choice.
First Thanks for your reply guys...
Still i didn't get...
I am using the ADODB.connection for recordset ie. Dim r As ADODB.Recordset
for adding i am using r.fields("File name")=string
I am using the datagrid for display the recordset... Now i want to delete the "datagrid1.text" row completly..... What to do :confused?
ThisQuote:
Originally Posted by kpmsivachand
Or, I'm a fan of the Listview.Quote:
Originally Posted by RhinoBull
I cann't get u?Quote:
Originally Posted by Hack
As RhinoBull suggested, don't use the DataGrid. It is a bound control which by its very nature, is limiting in how it can be manipulated.
Switch to a FlexGrid (his control of choice) or a ListView (my control of choice) and load the control of your choice from a recordset that you create based on an SQL query.
Your Datagird is BOUND to a Recordset object - you cannot just delete line from the grid without actually deleting it first from the underlying recordset.
If you are not using data control then get rid of Adodc1 in my sample.
Ok i will try using the flexgrid.... But in the listview, can we make the mulitiple coloumns in a single row?Quote:
Originally Posted by Hack
You betcha :thumb:Quote:
Originally Posted by kpmsivachand
Hack, is that everything we do with FlexGrid or most of the feature of FlexGrid is handled using ListView? If possible can you suggest me a sample please.. I am in eager to use the alternative controls for list of Information. Thanks....
I haven't used a FlexGrid is so long, I'm can't remember exactly what it does do. However, if you are interested in exploring either the FlexGrid or the ListView, then I would ask that you create your own thread for this topic.
Thanks.