0

How do I set the alignment of column names in a datatable in vb.net?

please recommend the best solution. KtReport1 is a winform library i.e. Kimtoo.Reports Visit https://www.nuget.org/packages/Kimtoo.Reports/

Thanks

Dim dt As DataTable = New DataTable()
da.Fill(dt)
Dim dtCloned As DataTable = dt.Clone()
dtCloned.Columns("PRICE").DataType = GetType(String)
dtCloned.Columns("DPR").DataType = GetType(String)
For Each row As DataRow In dt.Rows
    dtCloned.ImportRow(row)
Next row
dtCloned.Columns("PRICE").Convert(Function(val) Double.Parse(val.ToString()).ToString("N2"))
dtCloned.Columns("DPR").Convert(Function(val) Double.Parse(val.ToString()).ToString("N2"))
KtReport1.AddDataTable(dtCloned)
roy
  • 693
  • 2
  • 11
  • 2
    What is KTReport1? Do you have any markup? A data table isn't a display item, rather it is a collection of data. To display, it needs to be bound to something which handles the display and formatting. That looks to be ktreport1. Please edit your OP with that markup and some more context. – ClearlyClueless Jan 25 '23 at 12:32
  • @ClearlyClueless , KtReport1 is a winform library i.e. Kimtoo.Reports – roy Jan 25 '23 at 13:10
  • If you mean set positions on the grid then this may help [link](https://stackoverflow.com/questions/3757997/how-to-change-datatable-columns-order). – Julian Jan 25 '23 at 16:50
  • A datatable is not a directly displayable object, you rely on DataGrid (WPF), DataGridView (WinForms), etc. to show data contained in datatables. Can you better explain what do you need? – IFrank Jan 26 '23 at 11:32

0 Answers0