CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    May 2001
    Location
    Silicon Valley
    Posts
    113

    Question DataGrid displays lengths of strings instead of the actual strings

    Colleagues,

    Familiarizing myself with DataGrid (and with C# in general). My DataGrid is declared like this:
    Code:
     <my:DataGrid AutoGenerateColumns="True" Margin="74,32,68,103" Name="dataGrid1" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
    I’m setting the ItemSource property equal to a list of strings.

    Code:
            public Window1()
            {
                InitializeComponent();
    
                List<string> lstGridData = new List<string>();
                for (int i = 0; i < 8; ++i) lstGridData.Add("str");
                dataGrid1.ItemsSource = lstGridData;
            }
    I’m expecting that grid would display one column and each line would show “str”. Instead, the grid displays one column titled “Length” and each line displays “3”.

    What did I miss?

    Cheers,
    - Nick

    Update: some light was shed on this problem in this thread: http://www.codeproject.com/Messages/...ead-of-th.aspx
    Last edited by kender_a; November 18th, 2009 at 03:21 AM. Reason: Update

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured