Home Forums WPF controls Xceed DataGrid for WPF Insert item problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24247 |

    Hi,
    I created a DataGrid control which has 2 colums in design time (created with Blend). In run-time I add a new column (named “Yoav”), and add 2 items which contain 1 character for each column.

    My problem is that the first 2 columns (that was created by Blend) are empty and the text does not appear. (In the 3rd column its OK).

    Here is my code (where I add the 3rd column and add 2 rows):
    // add a column
    Column aYoavColumn = new Column();
    aYoavColumn.Title = “Yoav”;
    aYoavColumn.FieldName = “Yoav”;
    aYoavColumn.DisplayMemberBinding = new System.Windows.Data.Binding(“[2]”);
    (aYoavColumn.DisplayMemberBinding as System.Windows.Data.Binding).Mode = System.Windows.Data.BindingMode.TwoWay;
    MyGrid.Columns.Add(aYoavColumn);

    // fill the grid with two rows
    String[] rowData1 = new String[3];
    rowData1[0] = “A”;
    rowData1[1] = “B”;
    rowData1[2] = “C”;

    String[] rowData2 = new String[3];
    rowData2[0] = “A”;
    rowData2[1] = “B”;
    rowData2[2] = “C”;

    MyGrid.Items.Add(rowData1);
    MyGrid.Items.Add(rowData2);

    Can someone please explain why I do not see the text in the first 2 columns ?
    Note: the “DisplayMemberBinding” property in my first 2 columns is empty (I get an error message when I try to insert a value there).

    Yoav.

    Imported from legacy forums. Posted by Yoav (had 424 views)

    Xceed Support
    Member
    Post count: 5658

    Setting the DisplayMemberBinding property should solve the problem. What value are you trying to set and what error are you getting when you are setting it?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 268 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried to set the value “[0]”
    In the field “DisplayMemberBinding” -> “Custom Expression…”
    and the error message I get is: “Unable to convert the given expression to a valid value. Exception: Does not support Value to String conversion.”

    Imported from legacy forums. Posted by Yoav (had 218 views)

    Xceed Support
    Member
    Post count: 5658

    The DisplayMemberBinding property takes a Binding (e.g., DisplayMemberBinding=”{Binding [0]}” ). Simply passing a string will not function.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 3754 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.