×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

binding array to datagridview

binding array to datagridview

binding array to datagridview

(OP)
I am a foxpro refugee and would like to know how to bind an array to a datagridview object. My goal is to provide users a way to enter and update the elements in an array.

RE: binding array to datagridview

I've personally been using a BindingList of custom objects, that way I can use the ComponentModel to define how exactly I want it displayed in the DataGridView without having to edit the DataGridView itself. To be clear.. I'm not positive of the best practices on this; this has just been working well for me.

in the main application I just do:

CODE

...
//POPULATE THE MANAGE REPORTS TAB
currentReportsView.DataSource = _configuration.Reports;
... 

The configuration has a private BindingList that it already populated...

CODE

...
       public BindingList<Report> Reports
       {
         get
         {
            return _reports;
         }
         set
         {
            _reports = value;
         }
       }
... 

And then to control how it is displayed:

CODE

...
       [Browsable(false)]
      public int ID
      {
          get
          {
              return _id;
          }
          set
          {
              _id = value;
              base.Descendants("ID").FirstOrDefault().Value = value.ToString();
          }
      }
       [DisplayName("Report Title")]
      public string ReportName 
       { 
          get
          { 
             return _reportName;
          }
          set
          {
             _reportName = value;
             base.Descendants("ReportName").FirstOrDefault().Value = value;
          }
       }
       [DisplayName("Watch Folder")]
      public string Target 
       {
          get
          {
             return _target;
          }
          set
          {
             _target = value;
             base.Descendants("Target").FirstOrDefault().Value = value;
          }
        }
... 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close