CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Threaded View

  1. #1
    Join Date
    May 2001
    Silicon Valley

    Question DataGrid displays lengths of strings instead of the actual strings


    Familiarizing myself with DataGrid (and with C# in general). My DataGrid is declared like this:
     <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.

            public Window1()
                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?

    - 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 02: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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.