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 9047201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:51:07+00:00 2026-06-16T11:51:07+00:00

I am trying to bind a binding list to a datagrid, with autogeneratecolumns set

  • 0

I am trying to bind a binding list to a datagrid, with autogeneratecolumns set to true. However no columns are showing and I am wondering why.

Code snippet:

datagridResults.AutoGenerateColumns = true;
List<MailItem> mailItems = new List<MailItem>();

//readPst() returns a List<MailItem> populated with MailItems from the specified PST.
mailItems = readPst(txtBoxPST.Text, "Archive Folders");
BindingList<MailItem> bl = new BindingList<MailItem>(mailItems);

datagridResults.DataSource = bl;
datagridResults.Refresh();

The datagrid ends up being blank. I am sure that the BindingList contains the MailItems, if I changed it from binding from the BindingList to a Foreach MailItem m in bl… manually adding the rows it works fine. So my best guess is that the AutoGenerateColumns doesn’t work with the MailItem class? I am not sure why though, or the best way to work around it.

The MailItem class is the Microsoft.Office.Interop.Outlook.MailItem class.

  • 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-06-16T11:51:09+00:00Added an answer on June 16, 2026 at 11:51 am

    just add ToList() and don’t need to refresh the DataGridView

    datagridResults.DataSource = bl.Tolist();

    Update

    This is how to read the MailItems in OutLook

    public static void DisplayInbox(ApplicationClass o)
    {
      // Get items in my inbox. 
      NameSpace outlookNS = o.GetNamespace("MAPI");
      MAPIFolder inboxFolder 
        = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
      // Print out some basic info. 
      Console.WriteLine("You have {0} e-mails.", 
        inboxFolder.Items.Count);
      Console.WriteLine();
      foreach(object obj in inboxFolder.Items)
      {
        MailItem item = obj as MailItem;
        if(item != null)
        {
          Console.WriteLine("-> Received: {0}", 
            item.ReceivedTime.ToString());
          Console.WriteLine("-> Sender: {0}", item.SenderName);
          Console.WriteLine("-> Subject: {0}", item.Subject);
          Console.WriteLine();
        }
      }
    }
    

    Source: An Introduction to Programming Outlook 2003 Using C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to bind my DataGrid columns to a list where the item
I am trying to bind a DataGrid to a generic list in WPF. The
I'm trying to bind a List<List<string>> to a DataGrid programatically. I'm using this List<List<string>>
Background I'm trying to bind my objects to a DataGrid I have a list
Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType
I'm trying to bind a list of data to a data grid, but can't
I'm trying to bind the visibility flags of a pair of grids, however they
I'm trying to bind a XAML ComboBox so that its list items are the
I'm trying to bind a list box in the simplest manner possible with the
I'm trying to bind a list of custom objects to a WPF Image like

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.