-
Jul 21st, 2014, 03:26 AM
#1
Thread Starter
Junior Member
Datagrid Wrapmode not working
Hi,
Im wondering if anyone could help me. I am trying to create a product report which displays all the items sold in a day. The columns will be Barcode, QTY, Product, Price. I use a datagrid with a SELECT query "SELECT Barcode, QTY, Product, Price FROM SalesLog". The fields "run off" the page so I am looking for a way to continue the fields on a new line. I have tried using the wrapmode method but I have had no luck with this so far.
My code is
Code:
Sub DataGrid_Work()
'Show in DataGrid.
'Best method to display table contents in a DataGrid.
Dim MyTable As New DataTable
'this displays the current sale from the active table
CMD.Connection = CN
CMD.CommandText = "Select Barcode, QTY, Product, Price From SalesLog"
DataR = CMD.ExecuteReader
Dim I As Integer
For I = 0 To MyTable.Rows.Count - 1
Next
MyTable.Load(DataR)
DG1.DataSource = MyTable
DG1.Refresh()
'these lines decide what width the columns would be
Dim columnwidth0 As DataGridViewColumn = DG1.Columns(0)
columnwidth0.Width = 110
Dim columnwidth1 As DataGridViewColumn = DG1.Columns(1)
columnwidth1.Width = 35
DG1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DG1.Columns.Item(1).DefaultCellStyle.WrapMode = DataGridViewTriState.True
Dim columnwidth2 As DataGridViewColumn = DG1.Columns(2)
columnwidth2.Width = 150
DG1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DG1.Columns.Item(2).DefaultCellStyle.WrapMode = DataGridViewTriState.True
Dim columnwidth3 As DataGridViewColumn = DG1.Columns(3)
columnwidth3.Width = 45
DG1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DG1.Columns.Item(3).DefaultCellStyle.WrapMode = DataGridViewTriState.True
End Sub
Any help is greatly appreciated.
Thanks
Kerrie
Tags for this Thread
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
|