Extra column to a DatagridView with binding source

Answered Extra column to a DatagridView with binding source

  • lunes, 14 de mayo de 2012 12:38
     
      Tiene código

    Hi!

    I have a datagridview with a datasource from a MySQL query. Works fine. However, I want to add an extra column and generate some data into the cells. This works fine too and shows up as intended. However, I cannot sort on that extra column and the contents of the cells in the column are cleared out if I sort on the other colums. I realize this is all because of the original datasource, but Im hoping there is a way to "connect" the extra column in somehow?

    Grid_SearcherResults.DataSource = dbconnection.bSource
    Grid_SearcherResults.Columns.Add("Location", "Location")
    
    'Then some code to set the value of the cells in the new column.. etc
    Thanks!

Todas las respuestas

  • lunes, 14 de mayo de 2012 12:58
     
     Respondida Tiene código

    Fixed! 

    Dim source As DataTable = dbconnection.bSource.DataSource
    source.Columns.Add("Location")
    Grid_SearcherResults.DataSource = source


    • Marcado como respuesta Untouchab1e lunes, 14 de mayo de 2012 12:58
    • Editado Untouchab1e lunes, 14 de mayo de 2012 12:59
    •  
  • miércoles, 16 de mayo de 2012 2:16
    Moderador
     
     

    Hi Untouchab1e,

    Thanks for your post.

    I’m glad to hear that you found a solution. Thanks for sharing the solution here and it will help the members who have similar issue.

    Have a nice day!


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us