Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

DataGrids and BindingContext

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Celmer - 07 May 2005 07:31 GMT
Can someone please help me with my code.  I have a datasetX with two tables,
tableA and tableB in the datasetX.  The tables have a DataRelation named
A_B_Relation.  How can I get the BindingManagerBase to be a Currency Manager
so that I can get the current position when there is movement in dataGrid1.
This is my code:

// set up the binding contexts for Master/Detail grids
dataGrid1->DataSource = datasetX;
dataGrid1->DataMember = S"tableA";
dataGrid2->DataSource = datasetX;
dataGrid2->DataMember = S"A_B_Relation";
...
...
// get the current position
BindingManagerBase* manager = Form1::BindingContext->Item[datasetX,
S"tableA"];
DataRowView* view = __try_cast<DataRowView*>(manager->Current);  // this
line fails with a Bad Cast exception

The above code produces a BindingManagerBase of type PropertyManager, not a
Currency Manager.  How can I get a CurrencyManager that will cast to a
DataRowView of the current position?  Please help.

Marcus Heege - 07 May 2005 16:06 GMT
Haven't tried it, but since your data source is datasetX, you should use

BindingManagerBase* manager = Form1::BindingContext->Item[datasetX];

instesad of

BindingManagerBase* manager = Form1::BindingContext->Item[datasetX, "tableA"];

HTH
Marcus Heege

> Can someone please help me with my code.  I have a datasetX with two tables,
> tableA and tableB in the datasetX.  The tables have a DataRelation named
[quoted text clipped - 19 lines]
> DataRowView of the current position?  Please help.
>  
John Celmer - 08 May 2005 14:11 GMT
Thanks. Your advice led to a resolution.  And as I also later needed a
DataRowView, I changed my source from a dataset to a dataview.  Thanks
again.

> Haven't tried it, but since your data source is datasetX, you should use
>
[quoted text clipped - 34 lines]
>> Currency Manager.  How can I get a CurrencyManager that will cast to a
>> DataRowView of the current position?  Please help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.