locked
datagrid tablestyle is ignored RRS feed

  • Question

  • Using the appropriate tools, I built and added a tablestyle to my grid but data is displayed as if the style were not provided.  The emulator displays field names rather than the specified column headings.  'dtHist' is a datatable with the appropriate columns.  If it has more columns, all dtHist columns are displayed even though they are not included in the tablestyle....  Acts as if my tablestyle is ignored.  Did I miss something?

     

    Dim dgStyle As New DataGridTableStyle

    dgMaintHist.DataSource = dtHist

    dgStyle.MappingName =

    "dtHist"

     

    Dim column As New DataGridTextBoxColumn

    column.HeaderText =

    "Machine"

    column.MappingName =

    "mach_no"

    column.Width = 40

    dgStyle.GridColumnStyles.Add(column)

    column =

    New DataGridTextBoxColumn

    column.HeaderText =

    "Date"

    column.MappingName =

    "actdate"

    column.Format =

    "d"

    column.Width = 40

    dgStyle.GridColumnStyles.Add(column)

    column =

    New DataGridTextBoxColumn

    column.HeaderText =

    "Action"

    column.MappingName =

    "action"

    column.Width = 40

    dgStyle.GridColumnStyles.Add(column)

    column =

    New DataGridTextBoxColumn

    column.HeaderText =

    "Part"

    column.MappingName =

    "part"

    column.Width = dgMaintHist.Width - 120 - 20

    dgStyle.GridColumnStyles.Add(column)

    dgMaintHist.TableStyles.Clear()

    dgMaintHist.TableStyles.Add(dgStyle)

    Sunday, August 23, 2009 1:58 PM

Answers

  • In case of DataTable mapping name should be table's name. So that means what "dtHist" is probably not the proper name.

    Consider using dtHist.TableName instead of hard coded string.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Paul Diston Sunday, August 23, 2009 6:02 PM
    • Marked as answer by HowardW Sunday, August 23, 2009 11:55 PM
    Sunday, August 23, 2009 4:38 PM

All replies

  • Thanks for the response.  Tried setting the mappingname to "DataTable" - no change in results.  dtHist is of type DataTable.

    Sunday, August 23, 2009 3:17 PM
  • In case of DataTable mapping name should be table's name. So that means what "dtHist" is probably not the proper name.

    Consider using dtHist.TableName instead of hard coded string.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Paul Diston Sunday, August 23, 2009 6:02 PM
    • Marked as answer by HowardW Sunday, August 23, 2009 11:55 PM
    Sunday, August 23, 2009 4:38 PM