Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2007, 03:11 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default Set Form DataSet Position to DataGrid Selection

Hi All,

I am trying to implement the above, and would really appreciate some help as I am stuck!

I have a tabbed form, on one tab, we have the "data entry" stuff, text boxes, combos etc, and on the other tab is "search" stuff, which is basically a DataGrid which can be filtered and sorted etc.

What I am trying to do is allow the user to select a record in the DataGrid, and then set the Forms CurrencyManager position to the same record, so they can then edit the records values.

I have tried searching both Google and P2P but to no avail :(

Any help/pointers gratefully received,

Best Regards,

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
__________________
Rob
http://cantgrokwontgrok.blogspot.com
Reply With Quote
  #2 (permalink)  
Old September 9th, 2007, 04:11 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi All,

OK, Here's what I have so far. The problem I had was getting the Selected DataSet Position in the GridView. I have been able to get the code working by using a DataView (with a DataSource of the same DataSet as the Form) for the DataGrid DataSource. I then pulled the position from the DataGrid by searching for the ID in the DataView. I then siply set the Form's BindingContext to the same position.

Here's my current code:
Code:
// Get the currently Selected ID from the DataGrid.
const int ID_COL_IDX = 0;
int rowIdx = dataGrid.CurrentRowIndex;                
long SelID = (long)dataGrid[rowIdx, ID_COL_IDX];

// Find the ID in the DataView and Set the Form DataSet Position
int dvPos = dataView1.Find(SelID);
this.BindingContext[dsRegister, "Student"].Position = dvPos;
If anyone has any other solutions then I'd love to hear them!

Thanks,

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
Reply With Quote
  #3 (permalink)  
Old September 9th, 2007, 04:28 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Another Update!

Found a (IMO) much better way of doing it! :D
Code:
// Set the Current Student to the Student Selected in the DataView.
this.BindingContext[dsRegister, "Student"].Position =
this.BindingContext[dsRegister.Student].
Position;

// Set the Tab to the Entry Form
Tabs.SelectedTab = EntryTab;
How much simpler is that?! =D No DataView or anything..

I think its quite cool that the currency managers really do Manage!

Maybe they should get into consulting for managers at work ;)

Hope this helps others!

Best Regards,

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Set the Selection in Dropdownlist Control akhilhp ASP.NET 2.0 Basics 3 May 27th, 2007 07:13 AM
Set window position using button blkskullwork Javascript 5 January 18th, 2007 04:51 PM
How to set cursor position in a textbox? zayasv VB.NET 2 April 29th, 2006 07:09 AM
Set Default selection in ListBox nmreid Classic ASP Basics 0 January 20th, 2006 04:49 PM



All times are GMT -4. The time now is 04:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.