EngineerRegex
EngineerRegex

Reputation: 55

WPF VB DataGridCombox DataGridRow

I have gone at this for days and cant find a solution please help.

I have a WPF application I have a DataGridCombobox it has stuff in it (list of Arguments). I can also add free hand typed text into the Combobox like "Test" as shown in the graphic below.

enter image description here

When I add "Test" and click away or add new row I should see "Test" in the Combobox Drop Down List. Instead I see "xFRACASDataController.xFRACASFieldMapper+FieldMappingRow" Where the heck is "Test"

enter image description here

Here is vb.

 Private Sub xDcMappingDataGrid_CellEditEnding(sender As Object, e As DataGridCellEditEndingEventArgs) Handles xDcMappingDataGrid.CellEditEnding
    'get the list from the data grid on mapping tab

    Dim listOfRows As New ObservableCollection(Of FieldMappingRow)
    listOfRows = dataMapViewModel.DgRecords
    'For Each r In xDcMappingDataGrid.Items
    '    'stringList.Add(r)
    '    listOfRows.Add(r)
    'Next

    dataMapViewModel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)
    'dataMapViewModel.AddtoArgumentDropDownList(sender.ArgumentDropDownList(1))
    'dataMapViewModel.AddtoArgumentDropDownList(sender.Items.ToString)
    'dataMapViewModel.AddtoArgumentDropDownList(sender.dataGridRow.Item.ToString)
    'dataMapViewModel.AddtoArgumentDropDownList("TESTING1")
    'dataMapViewModel.AddtoArgumentDropDownList("TESTING2")
    'dataMapViewModel.AddtoArgumentDropDownList("TESTING3")
End Sub

and here is the F# Code

member x.AddtoArgumentDropDownList(argumentText:string) =
          argumentDropDownList.Add(argumentText)
    //Add new Argument in Text to argumentDropDownList
    //Check to see if Text is already in the argumentDropDownList
    //If its there throw it way
    //if Not add it to the argumentDropDownList

    member x.ArgumentDropDownList
        with get() = argumentDropDownList
        and set(t: List<string>) =
            argumentDropDownList.Clear()
            for aField in t do
                argumentDropDownList.Add(aField)
            x.TriggerPropertyChanged("ArgumentDropDownList")

    member x.Arg1
        //with get() = argumentDropDownList
        with set(t: string) =
            //argumentDropDownList.Clear()
            //for aField in t do
            argumentDropDownList.Add(t)
            x.TriggerPropertyChanged("ArgumentDropDownList")

IF I hand Jam "TESTING1" its in the Combobox Drop down. I have added a watch to Items.CurrentItem. shown below. "Test" is in Arg1

enter image description here

But not in the physical list itself. Any help is greatly Helpful.

Upvotes: 2

Views: 51

Answers (1)

Tomas Petricek
Tomas Petricek

Reputation: 243096

Note that you are not very likely to get a good answer to your question, because it is very specific and there is no way for us to run your code.

However, xFRACASDataController.xFRACASFieldMapper+FieldMappingRow is a kind of string that you'd get when you run ToString on an object that does not implement any clever formatting as text - it seems to be the name of a class, in this case FieldMappingRow (which is a nested class in xFRACASFieldMapper).

In the code you posted, you are calling ToString in the VB code on line:

dataMapViewModel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)

What is the type of sender.Items.CurrentItem? Is this perhaps an instance of FieldMappingRow? If so, then I think you need to extract the text from the object in some other way than by calling ToString.

Upvotes: 2

Related Questions