Question from datagrid to textbox

beegee

Member
Joined
Nov 26, 2012
Messages
6
Programming Experience
1-3
i have a datagrid and i am not sure which event to use or how to use it. I want a situation whereby a user clicks or selects an item and it shows in a textbox then i have a button that will delete that item from the database
 
I'm guessing that what you really have is a DataGridView and you don't need any code to make the selected record appear in TextBoxes or the like. Simply bind your data to both, e.g.
myBindingSource.DataSource = myDataTable
myDataGridView.DataSource = myBindingSource
myTextBox.DataBindings.Add("Text", myBindingSource, "SomeColumn")
To delete the current row you simply call RemoveCurrent on the BindingSource. That will flag the row as deleted and then, when you call Update on your data adapter, all your changes will be saved to the database, just like calling Fill on the data adapter retrieved the data in the first place.
 
Back
Top