By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,696 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,696 IT Pros & Developers. It's quick & easy.

Strongly typed data - the 'current row'

P: n/a
I've got a Windows Forms app talking to an Access db, and I'm
experimenting with VS2005's form data binding stuff etc.

I've got a dataset, a datagridview bound to a query (let's call it
Customers), and I have a button called Edit, which when clicked should
spawn a dialog wherein the customer associated with the current row in
the grid should be edited.

So I need to pass the 'current' Customer ID to this form. There's an
topic in the help titled "Walkthrough: Passing Data Between Forms in a
Windows Application" wherein a similar thing happens: to quote,

"Using the customers and orders tables from Northwind one form will
allow users to select a customer and a second form will display the
selected customer's orders. This walkthrough shows how to create a
method on one form that receives data from the first form."

The relevant part of the walkthrough is this:

Private Sub CustomersDataGridView_DoubleClick(ByVal sender As Object,
ByVal e As System.EventArgs) _
Handles CustomersDataGridView.DoubleClick

Dim SelectedRowView As Data.DataRowView
Dim SelectedRow As NorthwindDataSet.CustomersRow

SelectedRowView = CType(CustomersBindingSource.Current,
System.Data.DataRowView)
SelectedRow = CType(SelectedRowView.Row,
NorthwindDataSet.CustomersRow)

Dim OrdersForm As New Form2
OrdersForm.LoadOrders(SelectedRow.CustomerID)
OrdersForm.Show()
End Sub

My question is - what's with all these CTypes? I've (or rather, the IDE
has) gone to all this trouble to make a whole bundle of strongly-typed
types for my dataset, my datatables, my tableadapters, my columns, my
rows, change events etc etc (the xsd file is enormous when you look at
it in code!) - and yet just to say 'the current value of column X for
data object Y' I have to do 2 CTypes?

Surely there's a cleaner way of just saying 'the current customer ID' ?

--
Larry Lard
Replies to group please

Feb 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
CMM
Bind the CustomerId to a control on the form (hidden or otherwise) and pick
it up from that and bypass having to use the navigator objects to get it.

OrdersForm.LoadOrders(Me.CustomerIDLabel)

--
-C. Moya
www.cmoya.com
Feb 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.