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 / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Binding a TextBox to a DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peder Y - 18 Apr 2005 22:53 GMT
How do I bind a TextBox to a DataGrid? If I bind it to the DataGrid
DataTable, the TextBox doesn't get updated when I select another row. Do
I need to handle some DataGrid events?

- Peder -
Peder Y - 18 Apr 2005 23:39 GMT
It took some @£$½£$@£-work and swearing, but I finally found the
solution to my problem. For others with the same problems I repost what
I found. The following code is from another post and it proved useful:

http://groups.google.com/groups?hl=no&lr=&c2coff=1&selm=4lbhr056e0i0k48hondf8o89
cop47uugsa%404ax.com&rnum=9


dataGrid1.DataSource = myCustomersDataset.Customers
dataGrid1.DataMember = ""
textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",
myCustomersDataset.Customers, "CompanyName"))

dataGrid2.DataSource = myCustomersDataset
dataGrid2.DataMember = "Customers"
textBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.myCustomersDataset, "Customers.CompanyName"))

Mixing these two versions of using the bindings results in (in my case)
the TextBox being bound to the first row of the grid and getting stuck
there unless the CurrencyManager.Position is updated manually. Very
frustrating, but I hope this might shed some light on the situation for
others that suffer the same problem as I.

Cheers!

- Peder -

> How do I bind a TextBox to a DataGrid? If I bind it to the DataGrid
> DataTable, the TextBox doesn't get updated when I select another row. Do
> I need to handle some DataGrid events?
>
> - Peder -

Rate this thread:







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.