DataGridView не заполняет данные в ячейках - PullRequest
0 голосов
/ 06 февраля 2012

Я строю представление данных при загрузке формы. Код создает необходимые значения, но в результате сетка добавляет правильное количество строк, но данные никогда не отображаются в ячейках. Код следует;

Private Sub frmADRORD_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    ' Fill in the data grid with a List
    ' Get a DataTable instance from helper function.
    Dim dt As New DataTable
    dt = GetTable()
    'BindingSource1.DataSource = dt
    datagridADRORD.DataSource = dt
End Sub

''' Helper function that creates new DataTable.
''' </summary>
Function GetTable() As DataTable
    ' Create new DataTable instance.
    Dim table As New DataTable
    ' Create four typed columns in the DataTable.
    table.Columns.Add("ADR Symbol", GetType(String))
    table.Columns.Add("ADR Price", GetType(Double))
    table.Columns.Add("ORD Symbol", GetType(String))
    table.Columns.Add("ORD Price", GetType(Double))
    table.Columns.Add("Ratio", GetType(Double))
    table.Columns.Add("Currency", GetType(String))
    table.Columns.Add("Currency Price", GetType(Double))
    table.Columns.Add("Difference", GetType(Double))
    table.Columns.Add("GoNoGo", GetType(String))

    'start to loop thru all the symbols in the symbols file
    ' first read them into an array
    'the line below is for the commodity symbols file 
    Dim strText As String = File.ReadAllText("F:\ADR-ORD Program\ADR-ORD Comparator\ADR-ORD Comparator\SymbolsinBBRGFormat.txt")
    Dim aryText() As String = strText.Split(";")
    strText = vbNullString
    Dim x As Integer
    Dim symADR As String = "", symORD As String = 0, strCurncy As String = ""
    Dim dblADRPx As Double = 0, dblORDPx As Double = 0, dblCurncyPx As Double = 0
    Dim ratio As Double = 1, diff As Double = 0, goNogo As String = ""


    For x = 0 To UBound(aryText) - 1
        Dim newADRrow As DataRow = table.NewRow()

        newADRrow("ADR Symbol") = Split(aryText(x), ",")(0)
        newADRrow("ADR Price") = 1 'add bbrg formula here?
        newADRrow("ORD Symbol") = Split(aryText(x), ",")(1)
        newADRrow("ORD Price") = 1 ' add bbrg formula here?
        newADRrow("Ratio") = Split(aryText(x), ",")(2)
        newADRrow("Currency") = Split(aryText(x), ",")(3)
        newADRrow("Currency Price") = 1
        newADRrow("Difference") = 1
        newADRrow("GoNoGo") = "Go"
        MsgBox(newADRrow.ToString())
        ' Add rows of data for those columns filled in the DataTable.
        table.Rows.Add(newADRrow)

    Next x
    Return table
End Function
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...