none
don't show value in DataGridView ?

    Question

  • my code :

     Private _table As New DataTable()
    
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            _table.Columns.Add("col1")
            _table.Columns.Add("col2")
            Dim row As DataRow = _table.NewRow()
            row(0) = "Datagridview and richtextbox for bold substring in VB.net"
            row(1) = "Datagridview and richtextbox for bold substring in VB.net"
            _table.Rows.Add(row)
            _table.AcceptChanges()
            Me.dataGridView1.AutoGenerateColumns = False
            Me.dataGridView1.DataSource = _table
        End Sub

    Saturday, April 01, 2017 5:38 PM

Answers

  • Hi

    Does this help?

    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
        Private _table As New DataTable()
        Private Sub Form1_Load(sender As System.Object, e As EventArgs) Handles MyBase.Load
            _table.Columns.Add("col1")
            _table.Columns.Add("col2")
            '    Dim row As DataRow = _table.NewRow()
            '   row(0) = "Datagridview and richtextbox for bold substring in VB.net"
            '   row(1) = "Datagridview and richtextbox for bold substring in VB.net"
            _table.Rows.Add("First Row Cell2", "First Row Cell1 ")
            _table.Rows.Add("Second Row Cell2", "Second Row Cell1 ")
            '  _table.Rows.Add(row)
            '   _table.AcceptChanges()
            '    Me.DataGridView1.AutoGenerateColumns = False
            Me.DataGridView1.DataSource = _table
        End Sub
    


    Regards Les, Livingston, Scotland

    • Marked as answer by srajmuneer Saturday, April 01, 2017 7:31 PM
    Saturday, April 01, 2017 6:28 PM

All replies

  • Hi

    Does this help?

    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
        Private _table As New DataTable()
        Private Sub Form1_Load(sender As System.Object, e As EventArgs) Handles MyBase.Load
            _table.Columns.Add("col1")
            _table.Columns.Add("col2")
            '    Dim row As DataRow = _table.NewRow()
            '   row(0) = "Datagridview and richtextbox for bold substring in VB.net"
            '   row(1) = "Datagridview and richtextbox for bold substring in VB.net"
            _table.Rows.Add("First Row Cell2", "First Row Cell1 ")
            _table.Rows.Add("Second Row Cell2", "Second Row Cell1 ")
            '  _table.Rows.Add(row)
            '   _table.AcceptChanges()
            '    Me.DataGridView1.AutoGenerateColumns = False
            Me.DataGridView1.DataSource = _table
        End Sub
    


    Regards Les, Livingston, Scotland

    • Marked as answer by srajmuneer Saturday, April 01, 2017 7:31 PM
    Saturday, April 01, 2017 6:28 PM
  • Hello,

    Please don't post the same topic more than once as per this (your) thread with the same topic/question.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Saturday, April 01, 2017 7:25 PM
    Moderator
  • thanks Kareninstructor , I'm sorry I'm try with your address and convert c# to vb.net but not work
    • Edited by srajmuneer Saturday, April 01, 2017 7:30 PM
    Saturday, April 01, 2017 7:30 PM