Home › Forums › WinForms controls › Xceed Grid for WinForms › Help in creating handler
-
AuthorPosts
-
#15507 |
I know absolutely nothing about creating handlers only how to use them. So with that in mind, can someone help me construct a handler (and where the code needs to be placed inside my form) that will allow me to:
Execute a Database update and a DataSet Acceptchanges whenever a value is changed inside either a Master Grid, or detail grid?
I know I need to use the Cell.ValueChanged event but I can’t ever get to it or find it.
master Gridcontrol is named Grid
detailgrid(0) is named detail which is the master of detail2
detailgrid(1) is named detail2I can get to the cells from the master but can never figure out how to get to the cells in either of the detail grids.
The tutorials for Xceed grids only do the easy stuff that I understand it’s when things get more complex that I can’t find any info on how it must be accomplished.
Thanks
Imported from legacy forums. Posted by Greg (had 3858 views)
Are you using C# or VB.NET?
Imported from legacy forums. Posted by André (had 294 views)
Oh, sorry. VB.NET thanks
Imported from legacy forums. Posted by Greg (had 472 views)
Here is a code snippet that shows a very basic implementation of this, and is certainly not recommended with large datasets. It is only an illustration, so you can get you going when using events and DB objects.
<code>
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load‘the binding can be done in the designer
GridControl1.SetDataBinding( DataSet11.Customers, “” )
detailGridTemplate1.SetDataBinding( DataSet11.Customers, “CustomersOrders” )
detailGridTemplate2.SetDataBinding( DataSet11.Customers, “CustomersOrders.OrdersOrder_x0020_Details” )For Each cell As Cell In dataRowTemplate1.Cells
AddHandler cell.ValueChanged, AddressOf cell_ValueChanged
NextOleDbDataAdapter1.Fill(DataSet11)
OleDbDataAdapter2.Fill(DataSet11)
OleDbDataAdapter3.Fill(DataSet11)End Sub
Private Sub cell_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
‘this updates the DB
OleDbDataAdapter1.Update(DataSet11)
OleDbDataAdapter2.Update(DataSet11)
OleDbDataAdapter3.Update(DataSet11)End Sub
</code>Imported from legacy forums. Posted by André (had 229 views)
thank you. The part that I was missing and couldn’t figure out was the For Each cell as cell in dataRowTemplate1.Cells snippet.
I wanted to keep going to detailgrids(0) and couldn’t ever get what I needed.
Thanks again.
Imported from legacy forums. Posted by Greg (had 385 views)
Of course, you will need to do the same for every DataRowTemplate, since the grid adds one every time you add a DetailGridTemplate (that is, each DetailGridTemplate has its own DataRowTemplate).
Imported from legacy forums. Posted by André (had 4982 views)
-
AuthorPosts
- You must be logged in to reply to this topic.