none
Datagridview to excel - Vertical Headers and data RRS feed

  • Question

  • Hi All,

    I'm trying to create a datagridview that changes the headers and data from horizontal to vertical. Unfortuntatly i'm unable to succeed at this moment. The data inserted into textbox1 is being exported to excel when button1 is pressed, but it isn't making the changes required. Below is the code from my project application;

    Imports System.Data.DataTable
    Imports System.IO
    Imports Microsoft.Office.Interop
    Imports System.Runtime.InteropServices
    Public Class Form1
        Dim ds As DataSet = Nothing
        Dim dt As DataTable = Nothing
        Dim table As New DataTable("table")
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            ds = New DataSet()
            dt = New DataTable()
    
    
            ds.Tables.Add(dt)
    
            Dim my_DataView As DataView = ds.Tables(0).DefaultView
            Me.DataGridView1.DataSource = my_DataView
            DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
            DataGridView1.RowTemplate.Height = 120
            DataGridView1.AllowUserToAddRows = True
            table.Columns.Add("Name", Type.GetType("System.String"))
    
        End Sub
    
    
        Public Function FlipDataSet(my_DataSet As DataSet) As DataSet
            Dim ds As New DataSet()
    
            For Each dt As DataTable In my_DataSet.Tables
                Dim table As New DataTable()
    
                For i As Integer = 0 To dt.Rows.Count
                    table.Columns.Add(Convert.ToString(i))
                Next
                Dim r As DataRow
                For k As Integer = 0 To dt.Columns.Count - 1
                    r = table.NewRow()
                    r(0) = dt.Columns(k).ToString()
                    For j As Integer = 1 To dt.Rows.Count
                        r(j) = dt.Rows(j - 1)(k)
                    Next
                    table.Rows.Add(r)
                Next
    
                ds.Tables.Add(table)
            Next
    
            Return ds
        End Function
    
        Private Sub butNormal_Click(sender As Object, e As EventArgs) Handles ButNormal.Click
            Dim my_DataView As DataView = ds.Tables(0).DefaultView
            Me.DataGridView1.DataSource = my_DataView
    
            Butflip.Enabled = True
            ButNormal.Enabled = False
        End Sub
    
        Private Sub butFlip_Click(sender As Object, e As EventArgs) Handles Butflip.Click
            Dim new_ds As DataSet = FlipDataSet(ds)
            ' Flip the DataSet
            Dim my_DataView As DataView = new_ds.Tables(0).DefaultView
            Me.DataGridView1.DataSource = my_DataView
    
            Butflip.Enabled = False
            ButNormal.Enabled = True
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
            DataGridView1.RowTemplate.Height = 120
            DataGridView1.AllowUserToAddRows = False
            DataGridView1.DataSource = table
            table.Rows.Add(TextBox1.Text)
    
            'Save to excel with headers
            Dim ExcelApp As Object, ExcelBook As Object
            Dim ExcelSheet As Object
            Dim j As Integer
            Dim Proceed As Boolean = False
    
    
    
            'create object of exce
            ExcelApp = CreateObject("Excel.Application")
            ExcelBook = ExcelApp.WorkBooks.Add
            ExcelSheet = ExcelBook.WorkSheets(1)
    
            With ExcelSheet
                For Each column As DataGridViewColumn In DataGridView1.Columns
                    .cells(1, column.Index + 1) = column.HeaderText
                Next
                For i = 1 To Me.DataGridView1.RowCount
                    .cells(i + 1, 1) = Me.DataGridView1.Rows(i - 1).Cells("Name").Value
                    For j = 1 To DataGridView1.Columns.Count - 1
                        .cells(i + 1, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value
                    Next
                    Dim formatRange As Excel.Range
                    formatRange = ExcelSheet.Range("a1")
                    formatRange.EntireRow.Font.Bold = True
                    formatRange = ExcelSheet.Range("A1", "A1")
                    formatRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightBlue)
                    formatRange.BorderAround(Excel.XlLineStyle.xlContinuous)
                    formatRange = ExcelSheet.Range("a1", "A1")
                    formatRange.EntireRow.BorderAround()
                Next
            End With
    
            ExcelApp.Visible = True
            '
            ExcelSheet = Nothing
            ExcelBook = Nothing
            ExcelApp = Nothing
    
            Application.Exit()
            End
        End Sub
    End Class


    I was told to follow the following tutorial; www.codeproject.com/Articles/19313/Displaying-Vertical-Rows-in-DataGrid-View but sadly after converting from c# 2005 to vb.net 2013 i'm unable to embed it into my custom application and make it work.

    Please can anyone provide guidance?

    Monday, May 29, 2017 3:28 PM

All replies

  • Hello,

    Please specify what is not working, be very specific.


    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

    Monday, May 29, 2017 4:04 PM
    Moderator
  • Hi Karen,

    I'm trying to make the datagridview column header called 'Forename' show in for example cell A1 with the name typed in textbox1 show in B1. At this moment the Forename header shows in A1 and the data typed in textbox1 shows in A2.

    Monday, May 29, 2017 7:22 PM
  • I'll be honest, late binding Excel is not my thing, never done it. If open to an alternate method, try the following code sample which uses a free library SpreadSheetLight (on GitHub) where if Excel is not installed it still works. There is one dependency, DocumentFormat.OpenXml (SpreadSheetLight uses version 2.5) 

    Now what is demo'd may not be an exact match for you but does gives you a pathway to work with.

    VB.NET Screenshot

    Results

    Form code

    Public Class Form1
        Private ops As New Operations
        Private ds As DataSet = Nothing
        Private dt As DataTable = Nothing
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ds = New DataSet()
            dt = New DataTable()
    
            dt = GetCustomers()
            ds.Tables.Add(dt)
    
            Dim my_DataView As DataView = ds.Tables(0).DefaultView
            DataGridView1.DataSource = my_DataView
        End Sub
        Private Function GetCustomers() As DataTable
            Dim table As New DataTable()
            table.TableName = "Customers"
    
            table.Columns.Add("Name", GetType(String))
            table.Columns.Add("Price", GetType(String))
            table.Columns.Add("Country", GetType(String))
    
            table.Rows.Add(New Object() {"Mohamad", "1700", "Egypt"})
            table.Rows.Add(New Object() {"Tarek", "550", "Syria"})
            table.Rows.Add(New Object() {"Gamal", "762", "Saudi Arabia"})
    
            table.AcceptChanges()
    
            Return table
    
        End Function
        Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
            Dim ds As New DataSet()
    
            For Each dt As DataTable In my_DataSet.Tables
                Dim table As New DataTable()
    
                For i As Integer = 0 To dt.Rows.Count
                    table.Columns.Add(Convert.ToString(i))
                Next
                Dim r As DataRow
                For k As Integer = 0 To dt.Columns.Count - 1
                    r = table.NewRow()
                    r(0) = dt.Columns(k).ToString()
                    For j As Integer = 1 To dt.Rows.Count
                        r(j) = dt.Rows(j - 1)(k)
                    Next
                    table.Rows.Add(r)
                Next
    
                ds.Tables.Add(table)
            Next
    
            Return ds
        End Function
        Private Sub butFlip_Click(sender As Object, e As EventArgs) Handles butFlip.Click
    
            Dim currentDataSet As DataSet = FlipDataSet(ds) ' Flip the DataSet
            Dim currentDataView As DataView = currentDataSet.Tables(0).DefaultView
            DataGridView1.DataSource = currentDataView
    
            butFlip.Enabled = False
            butNormal.Enabled = True
        End Sub
        Private Sub butNormal_Click(sender As Object, e As EventArgs) Handles butNormal.Click
            Dim currentDataSet As DataView = ds.Tables(0).DefaultView
            DataGridView1.DataSource = currentDataSet
    
            butFlip.Enabled = True
            butNormal.Enabled = False
        End Sub
    
        Private Sub butExit_Click(sender As Object, e As EventArgs) Handles butExit.Click
            Close()
        End Sub
    
        Private Sub butExport_Click(sender As Object, e As EventArgs) Handles butExport.Click
            If Not String.IsNullOrWhiteSpace(txtSheetName.Text) Then
                Select Case ops.ExportDataTable(CType(DataGridView1.DataSource, DataView).Table, txtSheetName.Text)
                    Case OperationResults.Success
                        MessageBox.Show("Data written to file")
                    Case OperationResults.SheetExist
                        MessageBox.Show("Sheet already exists, aborted")
                    Case OperationResults.UnknownException
                        MessageBox.Show($"Operation throw an exception{Environment.NewLine}{ops.Exception.Message}")
                End Select
            End If
        End Sub
    End Class
    

    Class in the project to work with Excel.

    Imports SpreadsheetLight
    Public Enum OperationResults
        Success
        SheetExist
        UnknownException
    End Enum
    Public Class Operations
        Private theExportFileName As String =
            IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportSample.xlsx")
        Public ReadOnly Property ExportFileName As String
            Get
                Return theExportFileName
            End Get
        End Property
        Private theException As Exception
        Public ReadOnly Property Exception As Exception
            Get
                Return theException
            End Get
        End Property
        Public Function ExportDataTable(ByVal pTable As DataTable, ByVal pSheetName As String) As OperationResults
            Try
                Using sl As New SLDocument(ExportFileName)
                    Dim workSheets = sl.GetSheetNames(False)
                    If workSheets.Any(Function(sheetName) sheetName.ToLower = pSheetName.ToLower) Then
                        Return OperationResults.SheetExist
                    Else
                        sl.AddWorksheet(pSheetName)
                    End If
    
                    Dim iRow As Integer = 0
                    Dim theList = New List(Of DataItem)
                    For row As Integer = 0 To pTable.Rows.Count - 1
                        iRow += 1
                        theList = pTable.Rows(row).ItemArray _
                            .ToList _
                            .Select(Function(d, i) New DataItem With {.Text = d.ToString, .Index = i + 1}).ToList
                        sl.InsertRow(iRow, 1)
                        For Each item In theList
                            sl.SetCellValue(iRow, item.Index, item.Text)
                        Next
                    Next
                    sl.Save()
                    Return OperationResults.Success
                End Using
            Catch ex As Exception
                theException = ex
                Return OperationResults.UnknownException
            End Try
        End Function
    End Class
    Public Class DataItem
        Public Property Index As Integer
        Public Property Text As String
        Public Overrides Function ToString() As String
            Return $"{Index} - {Text}"
        End Function
    End Class
    


    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

    Monday, May 29, 2017 11:11 PM
    Moderator
  • Hi Karen,

    Thank you for the response.

    Please see my following project; My Project

    I had previously used the one you are suggesting as guidance when building this application. I have the following problem though that I can't resolve;

    1. When the user inserts a forename into 'Textbox1' and clicks 'button1' to export the data inserted it isn't being displayed. At this moment the header will be situated in ROW1 of any given column and the data will be displayed beneath the header. The aim is to have the headers be shown vertically in and the retrospective data be shown beside the column headers so for example, The Column header in ROW 1 A1 and the textbox text in ROW 2 cell B1

    Ultimately the way the example you provide with the flipped data being presented after pushing the button flippeddatagrid is how would like my reporting, but allowing the user to insert a forename rather than pre-inserting the headers and data in the string.





    • Edited by caf20012 Tuesday, May 30, 2017 10:31 AM
    Tuesday, May 30, 2017 5:57 AM
  • Hello,

    I have zero clue to what you last wrote, your formatting has garbled everything.

    No matter, doubt I will have time to look at this for several days as I'm starting a major iteration of a project this week. I will check in to see how things are going on Friday afternoon. 

    If you want someone to assist then clean up the last reply else we have no idea what you are saying. 


    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

    Tuesday, May 30, 2017 10:25 AM
    Moderator
  • Hi Karen!

    I have no idea i think it automatically added HTML format to my post.

    It has now been corrected.

    I have no doubt you'll be able to assist with my query, as you previously solved an issue no one else could!!

    Really appreciate your support as always and am very humble and thankful.

    Update: New Project

    I've managed to get the data inserted into textbox1 to populate once clicking flip or normal button, but it overwrites the header 'Forename' Do you know how i could overcome this issue?

    • Edited by caf20012 Tuesday, May 30, 2017 6:24 PM
    Tuesday, May 30, 2017 10:29 AM
  • Hi caf20012,

    I download the project and reproduce your issue on my side, please modify your code like this:

    Imports System.Data.DataTable
    Imports System.IO
    Imports Microsoft.Office.Interop
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private ds As DataSet = Nothing
        Private dt As DataTable = Nothing
        Dim table As New DataTable("table")
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ds = New DataSet()
            dt = New DataTable()
            dt = GetCustomers()
            ds.Tables.Add(dt)
            Dim my_DataView As DataView = ds.Tables(0).DefaultView
            DataGridView1.DataSource = my_DataView
    
        End Sub
        Private Function GetCustomers() As DataTable
            'Dim table As New DataTable()
            table.Columns.Add("Name", GetType(String))
            table.AcceptChanges()
            Return table
    
        End Function
        Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
            Dim ds As New DataSet()
    
            For Each dt As DataTable In my_DataSet.Tables
                Dim table As New DataTable()
                For i As Integer = 0 To dt.Columns.Count - 1
                    table.Columns.Add(dt.Columns(i).ColumnName, GetType(String))
                Next
                Dim r As DataRow
                For k As Integer = 0 To dt.Columns.Count - 1
                    r = table.NewRow
                    r(0) = dt.Columns(k).ToString()
                    For j As Integer = 1 To dt.Rows.Count
                        r(j) = dt.Rows(j - 1)(k)
                    Next
                    table.Rows.Add(TextBox1.Text)
                Next
    
                ds.Tables.Add(table)
            Next
    
            Return ds
        End Function
        Private Sub butFlip_Click(sender As Object, e As EventArgs) Handles butFlip.Click
    
            Dim currentDataSet As DataSet = FlipDataSet(ds) ' Flip the DataSet
            Dim currentDataView As DataView = currentDataSet.Tables(0).DefaultView
            DataGridView1.DataSource = currentDataview
    
            butFlip.Enabled = False
            ButNormal.Enabled = True
    
        End Sub
        Private Sub butNormal_Click(sender As Object, e As EventArgs) Handles butNormal.Click
            Dim currentDataSet As DataView = ds.Tables(0).DefaultView
            DataGridView1.DataSource = currentDataSet
    
            butFlip.Enabled = True
            butNormal.Enabled = False
        End Sub
    
    
        Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    
        End Sub
    
        Private Sub butexport_Click(sender As Object, e As EventArgs) Handles butexport.Click
            Dim table As New DataTable
            Dim ds As New DataSet
            'Save to excel with headers
            Dim ExcelApp As Object, ExcelBook As Object
            Dim ExcelSheet As Object
            Dim j As Integer
    
            'create object of exce
            ExcelApp = CreateObject("Excel.Application")
            ExcelBook = ExcelApp.WorkBooks.Add
            ExcelSheet = ExcelBook.WorkSheets(1)
    
            With ExcelSheet
                Dim Col As DataGridViewColumn
                Dim i As Integer = 1
                For Each Col In DataGridView1.Columns
                    .Cells(1, i).Value = Col.HeaderText
                    i += 1
                Next
                'Add data to excel sheet by looping through the rows
                'in the datagrid
                i = 2
                Dim RowItem As DataGridViewRow
                Dim Cell As DataGridViewCell
                For Each RowItem In DataGridView1.Rows
                    Dim k As Integer = 1
                    For Each Cell In RowItem.Cells
                        .Cells(i, k).Value = Cell.Value
                        k += 1
                    Next
                    i += 1
                Next
            End With
    
            ExcelApp.Visible = True
            '
            ExcelSheet = Nothing
            ExcelBook = Nothing
            ExcelApp = Nothing
        End Sub
    
       
    End Class
    

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 31, 2017 7:01 AM
    Moderator
  • REMOVED*

    • Edited by caf20012 Friday, June 2, 2017 10:19 AM
    Wednesday, May 31, 2017 8:47 PM
  • I have look at what others have done and made attempts that worked yet in my mind were unacceptable. With that I have no viable solution.

    What I will say is, this is a piece of cake working in web applications using Kendo UI library yet that does not translate to desktop apps. 


    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

    Thursday, June 1, 2017 12:27 AM
    Moderator
  • I have look at what others have done and made attempts that worked yet in my mind were unacceptable. With that I have no viable solution.

    What I will say is, this is a piece of cake working in web applications using Kendo UI library yet that does not translate to desktop apps. 


    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

    Hi Karen Payne,

    Appreciate your honesty.

    If you have anyone in mind who might be able to sort this problem out then please let them know as it will mean a great deal to me to resolve this matter. 

    Do you think Cherry's response: Thread might be the answer?

    Thursday, June 1, 2017 12:59 PM
  • In regards to Cherry's response, I don't think so by viewing the code.

    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

    Thursday, June 1, 2017 2:02 PM
    Moderator
  • Hi,

    How would i incorporate the project in your original post Karen, with Cole's response in my following application located below? The outcome would be when the user clicks to 'Generate' and it exports to excel it will firstly flip the datagrid and export based on the format of thedatagridviewbeing flipped.

    My Project

    Ignore my code above as it will be incredibly confusion which i've removed.

    Any suggestions?


    • Edited by caf20012 Friday, June 2, 2017 10:36 AM
    Friday, June 2, 2017 10:05 AM
  • Hi All,

    Further updated: 

    Imports System.Data.DataTable
    Imports System.IO
    Imports Microsoft.Office.Interop
    Public Class Form1
        Dim table As New DataTable(0)
        Public checkBoxList As List(Of CheckBox)
        Private ds As DataSet = Nothing
        Private dt As DataTable = Nothing
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ds = New DataSet()
            dt = New DataTable()
            ds.Tables.Add("Table")
            Dim my_DataView As DataView = ds.Tables(0).DefaultView
            DataGridView1.DataSource = my_DataView
            table.Columns.Add("Forename", Type.GetType("System.String"))
            table.Columns.Add("Surname", Type.GetType("System.String"))
            table.Columns.Add("Food", Type.GetType("System.String"))
            checkBoxList = New List(Of CheckBox) From {CheckBox1, CheckBox2, CheckBox3, CheckBox4}
    
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim currentDataSet As DataSet = FlipDataSet(ds) ' Flip the DataSet
            Dim values As String = "" &
            String.Join(" & ", checkBoxList _
            .Where(Function(cb) cb.Checked).Select(Function(cb) cb.Text))
    
            ' use values for placing into your DataGridView
            CheckBox1.Text = values
            CheckBox2.Text = values
            CheckBox3.Text = values
            CheckBox4.Text = values
    
    
            table.Rows.Add(TextBox1.Text, TextBox2.Text, values.ToString)
            DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
            DataGridView1.RowTemplate.Height = 100
            DataGridView1.AllowUserToAddRows = False
            DataGridView1.DataSource = table
    
            'Save to excel with headers
            Dim ExcelApp As Object, ExcelBook As Object
            Dim ExcelSheet As Object
            Dim i As Integer
            Dim j As Integer
    
            'create object of excel
            ExcelApp = CreateObject("Excel.Application")
            ExcelBook = ExcelApp.WorkBooks.Add
            ExcelSheet = ExcelBook.WorkSheets(1)
    
            With ExcelSheet
                For Each column As DataGridViewColumn In DataGridView1.Columns
                    .cells(1, column.Index + 1) = column.HeaderText
                Next
                For i = 1 To Me.DataGridView1.RowCount
                    .cells(i + 1, 1) = Me.DataGridView1.Rows(i - 1).Cells("Forename").Value
                    For j = 1 To DataGridView1.Columns.Count - 1
                        .cells(i + 1, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value
                    Next
                Next
    
            End With
    
            ExcelApp.Visible = True
            '
            ExcelSheet = Nothing
            ExcelBook = Nothing
            ExcelApp = Nothing
        End Sub
    
        Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    
        End Sub
        Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
            Dim ds As New DataSet()
    
            For Each dt As DataTable In my_DataSet.Tables
                Dim table As New DataTable()
    
                For i As Integer = 0 To dt.Rows.Count
                    table.Columns.Add(Convert.ToString(i))
                Next
                Dim r As DataRow
                For k As Integer = 0 To dt.Columns.Count - 1
                    r = table.NewRow()
                    r(0) = dt.Columns(k).ToString()
                    For j As Integer = 1 To dt.Rows.Count
                        r(j) = dt.Rows(j - 1)(k)
                    Next
                    table.Rows.Add(r)
                Next
    
                ds.Tables.Add(table)
            Next
    
            Return ds
        End Function
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim currentDataSet As DataSet = FlipDataSet(ds) ' Flip the DataSet
            Dim currentDataView As DataView = currentDataSet.Tables(0).DefaultView
            DataGridView1.DataSource = currentDataView
    
            Button2.Enabled = False
    
        End Sub
    End Class
    

    Sadly, button2 to flipdata isn't working and makes the datagridview go blank with a column called '0'

    Any ideas?

    Friday, June 2, 2017 5:11 PM
  • Sorry to Bump?

    Anyone able to help on the above?

    Saturday, June 3, 2017 8:15 PM
  • Hi caf20012,

    Do you try the code that I provide?

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 8, 2017 7:54 AM
    Moderator