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 / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

DataBind to current row of a datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Morris [Droopy eyes software] - 08 Jan 2006 16:55 GMT
Hi all

As DataGrid is readonly I decided to add an UpDown control to the bottom of
my form in order to allow the user to edit a numerical value of the selected
row.

I have done this in code, but I suspect that there must be a way to do this
via databinding.  So my question is this, how can I databind the Value
property of my UpDown control to the CurrentRow.RecordedAmount, but when the
selected row changes the UpDown will be editing the newly selected row
instead?

Thanks

Pete
Ginny Caughey [MVP] - 09 Jan 2006 15:32 GMT
Peter,

I don't know of a way to do this automatically using data binding. Since you
have a coded solution already, I'd just go with that. It will give you more
control than an "automatic" one would if it were available anyway.

Signature

Ginny Caughey
.NET Compact Framework MVP

> Hi all
>
[quoted text clipped - 11 lines]
>
> Pete
Ilya Tumanov [MS] - 09 Jan 2006 19:43 GMT
In fact this scenario is automatically handled by CurrencyManager class in
data binding engine.

If you have DataTable bound to the grid and bunch of simple controls bound
to the same DataTable, CurrencyManager would bind simple controls to the
current row in the grid.

So, there's nothing to code besides setting up bindings like this:

dataGrid.DataSource = dataTable;

upDown.Bindings.Add("Value", dataTable, "RecordedAmount");

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactfra
mework?hl=en

2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

> Peter,
>
[quoted text clipped - 17 lines]
>>
>> Pete
Ginny Caughey [MVP] - 09 Jan 2006 20:54 GMT
Thanks, Ilya. I misread what he wanted to do and thought he wanted to change
the selected row in the grid based on the up/down control. But in any case,
as long as he has a working solution...

Signature

Ginny Caughey
.NET Compact Framework MVP

> In fact this scenario is automatically handled by CurrencyManager class in
> data binding engine.
[quoted text clipped - 46 lines]
>>>
>>> Pete
Peter Morris [Droopy eyes software] - 09 Jan 2006 23:39 GMT
Ah, I can databind to the datagrid then?  I will try that, thanks!

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.