why DataGridViewLinkColum doesn't show any of the data property in vb.net

55 Views Asked by At

why DataGridViewLinkColum doesn't show any of the data properties in vb.net?.

Is there something wrong with my code?. Please guide

is there any solution so it can appear in datagridview?

Thanks

  Private Sub BindItemDetail()
        If _myTable.Rows.Count = 0 Then
            Dim field() As String = {"No", "Codeproduct", "Barcode"}
            _myTable = DataControl.CreateDataTableDynamic(field)
        End If
        AddColumnsProgrammatically()
        Grid.DataSource = _myTable
    End Sub
    Private Sub FillDataTable(iRow As Integer, ByVal Codeproduct As String, ByVal Barcode As String)
        Dim row As DataRow = _myTable.NewRow()
        row("No") = iRow
        row("Codeproduct") = Codeproduct
        row("Barcode") = Barcode
        _myTable.Rows.Add(row)
    End Sub
    Private Sub AddColumnsProgrammatically()
        Dim Col1 = New DataGridViewTextBoxColumn()
        Dim Col2 = New DataGridViewTextBoxColumn()
        Dim Col3 = New DataGridViewTextBoxColumn()
        Dim Col4 = New DataGridViewLinkColumn()
        Dim Col5 = New DataGridViewLinkColumn()
        Col1.HeaderText = "No"
        Col1.Name = "Column1"
        Col1.DataPropertyName = "No"
        Col2.HeaderText = "CodeProduct"
        Col2.Name = "Column2"
        Col2.DataPropertyName = "CodeProduct"
        Col3.HeaderText = "Barcode"
        Col3.Name = "Column3"
        Col3.DataPropertyName = "Barcode"
        Col4.HeaderText = ""
        Col4.Name = "Column4"
        Col4.DataPropertyName = "❌"
        Col5.HeaderText = ""
        Col5.Name = "Column5"
        Col5.DataPropertyName = "✏"

        Grid.Columns.AddRange(New DataGridViewColumn() {Col1, Col2, Col3, Col4, Col5})
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        _myTable.Columns.Add("No", GetType(Integer))
        _myTable.Columns.Add("Codeproduct", GetType(String))
        _myTable.Columns.Add("Barcode", GetType(String))
        BindItemDetail()
    End Sub

view DataGridViewLinkColumn

1

There are 1 best solutions below

0
On

in accordance with the guidelines of @jmcilhinney

  Private Sub BindItemDetail()
        If _myTable.Rows.Count = 0 Then
            Dim field() As String = {"No", "Codeproduct", "Barcode", "❌", "✏"}
            _myTable = DataControl.CreateDataTableDynamic(field)
        End If
        AddColumnsProgrammatically()
        Grid.DataSource = _myTable
    End Sub
    Private Sub FillDataTable(iRow As Integer, ByVal Codeproduct As String, ByVal Barcode As String, Coldel As String, Coledit As String)
        Dim row As DataRow = _myTable.NewRow()
        row("No") = iRow
        row("Codeproduct") = Codeproduct
        row("Barcode") = Barcode
        row("❌") = Coldel
        row("✏") = Coledit
        _myTable.Rows.Add(row)
    End Sub