Greetings to all
I have the following code snippet from a sub-routine:
Dim objReader As SqlClient.SqlDataReader = clsDatabase.ReadSQL(pSQL)
pListView.Clear()
' Create the Columns
Dim objSchema As DataTable = objReader.GetSchemaTable
For i As Integer = 1 To objSchema.Rows.Count - 1
Dim row As DataRow = objSchema.Rows(i)
pListView.Columns.Add(row(0).ToString)
Next
clsDatabase.ReadSQL is a user-defined function that returns a SqlDataReader result from the given SQL
The purpose of this sub-routine is display the result of the SQL query in the ListView. Since I can pass any valid query that returns rows of indeterminiate column counts (and names), I wish construct the ColumnHeaders based on the returned results.
Using the For-Loop in the snippet, I was able to add and display the proper columns.
Unfortunately, I could not set the width property, nor the Alignment property, of each column.
Is there a way to retrieve the field information (declaration type and size) so that I can properly set the appropriate width, and set the correct alignment so that texts are left-aligned while numbers are right-aligned?
Thanks much for any assistance!
Best Regards,
Kevin
evolve or die.