|
-
Sep 25th, 2002, 08:16 AM
#1
Thread Starter
Fanatic Member
Format column width in datagrid
I added the following 2 lines to public class of a form:
Dim dsPick As New DataSet()
Dim dtPick As New DataTable("Pick")
I then added a grid to a form and in the form load() event added the following code:
dsPick.Tables.Add(dtPick)dtPick.Columns.Add(New DataColumn("Code",
GetType(String)))
dtPick.Columns.Add(New DataColumn("Description", GetType(String)))
dtPick.Columns.Add(New DataColumn("Quantity", GetType(String)))
Me.datagrid1.DataSource = dtPick
When the user clicks a button on the form the following code is executed. The code adds a record.
Public Sub AddToTable()
Dim row As DataRow
row = dtPick.NewRow()
row(0) = "TEST STRING 1"
row(1) = "TEST STRING 2"
row(2) = "TEST STRING 3"
dtPick.Rows.Add(row)
End Sub
At this stage everything works fine but all the columns are of equal width.
Can anyone tell me how I go about setting the column widths in code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|