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 Data Binding / September 2007

Tip: Looking for answers? Try searching our database.

How can I tell if a control is databound?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin P - 23 Aug 2007 12:29 GMT
Hi all

I'm trying to put together a method to loop through all controls on a
form and see if any of them are databound.

For simple binding this seems to be straight forward enough (by
checking the control.Bindings collection as in the example below), but
this doesn't work for combo boxes or datagridviews (and probably
numerous other items).

Does anyone know how I can check any type of control to establish
whether it's bound or not - whether it's simple or complex binding?

Thanks a lot in advance
Martin

Code snippet to check for simple binding - this would be called for
each control on a form:

'================
Public Sub GetBoundControls(ByVal caller As Control)
Dim ctl As Control
For Each ctl In caller.Controls
If ctl.DataBindings.Count > 0 Then
' do some work here
End If
Next
End Sub
'================
Roger Tranchez - 07 Sep 2007 11:00 GMT
Hi,

What if you Check its DataSource being Nothing / Null ?
Signature

Roger Tranchez
MCTS
.NET 2005 and DB developer

> Hi all
>
[quoted text clipped - 25 lines]
> End Sub
> '================

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.