Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:26:26+00:00 2026-05-14T03:26:26+00:00

In an assembly I created a class like the following: [DataObject(true)] public class A

  • 0

In an assembly I created a class like the following:

[DataObject(true)]
public class A
{
 public int Foo{get;set;}

 [DataObjectMethod[DataObjectMethodType.Select)]
 public static List<A> GetAllA(string ConnectionString)
 {
   // return filled List<A>
 }
}

Now I want to display this List with a Gridcontrol under Winforms. I though of a DataGrid.
Though I’m coming from ASP.net I’d first think of

this.dataGridView1.DataSource = A.GetAllA(ConnectionString)

Works, but I’d prefer a better databinding with BindingSources. (Because I’ve always heard that thats the way to go)
I managed to drop a BindingSource onto the form and set the DataSource property to class A.
But where can I set the SelectMethod and its parameters? If I set DataSource property of the dataGridView to the BindingSource, it will only display an empty line.

Is this the right way to go? Will it only require some additional clicks in the wizard, or do I need to read tons of documentation to get this working?

Edit: Is there even a way to achieve automatically binding to my select method? Or does the BindingSource only supports mapping the columns, but not actually binding the data, meaning I’m required to set the DataSource property nevertheless?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:26:27+00:00Added an answer on May 14, 2026 at 3:26 am

    You need to create a DataSource. Click “Data” menu and select “Add New DataSource…”

    Connecting to Data in Visual Studio Overview
    http://msdn.microsoft.com/en-us/library/wxt2cwcc(VS.80).aspx

    To connect your application to data in
    a database, Web service, or object,
    run the Data Source Configuration
    Wizard

    by selecting Add New Data Source from
    the Data Sources
    Window
    .

    Public Class A
        Private _field As String
        Public Property Field() As String
            Get
                Return _field
            End Get
            Set(ByVal value As String)
                _field = value
            End Set
        End Property
    End Class
    
    Public Class AListing
        Inherits List(Of A)
    End Class
    
    • Use AListing as the object when adding a data source. Good for grid views or detail forms that provide navigation. It is up to you to populate it.
    • Use A as the object when adding a data source. Good for a dialog when you only need to bind to one instance. It is up to you to populate it.

    A DataSource just helps the designer configure data binding. You still have to fill the objects. If you do not care about designer support, calling as you do is fine. Using a BindingSource just allows you to use an object like a “data table”. Using your example, if I use a BindingSource, I could handle the CurrentChanged event for any additional processing.

    this.dataGridView1.DataSource = A.GetAllA(ConnectionString);
    //-or-
    this.bindingSource1.DataSource = A.GetAllA(ConnectionString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have a C++ class like: class Foo { public: virtual ~Foo() {}
i have a winforms project, and i created a class on assembly A that
I have the following class Person: public class Person { public string Name {
I created a separate assembly to contain common extension methods, the extension methods uses
Suppose assembly Assembly1.dll contains 3 classes: Class C1, C2, C3. I want to expose
I created a VB.NET Class, and created a strong key, and added it to
I've created a .net assembly that includes the data contract for a WCF (win32)
Take the following example (created purely to demonstrate the point). What I am trying
I created an array sorter to sort arrays like in Win Explorer in a
Inside a container object, I have created a class Factory , that is responsible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.