VB.net 2005
Windows application.
1 form containing a datagridview
Using the following code I am filling a grid with data.
Windows application.
1 form containing a datagridview
Using the following code I am filling a grid with data.
Dim con As New SqlConnection
Dim stSql As String = ""
con = New SqlConnection("Data Source=" & pstServer & ";" & _
"Initial Catalog=" & pstDb & ";User Id=" & pstUser & ";Password=" & pstPass & ";")
con.Open()
Dim myds As DataSet = New DataSet
stSql = "SELECT SFORDFIL_SQL.ord_loc, IMITMIDX_SQL.prod_cat, SFORDFIL_SQL.byr_plnr, SFORDFIL_SQL.item_no, IMITMIDX_SQL.item_desc_1, " & _
"SFORDFIL_SQL.ord_no, SFORDFIL_SQL.ord_qty - SFORDFIL_SQL.qty_complete AS QtyRem, SFORDFIL_SQL.ord_status, SFORDFIL_SQL.sch_meth, " & _
"CONVERT(smalldatetime, CONVERT(varchar(8), SFORDFIL_SQL.due_dt)) AS due_dt, " & _
"CONVERT(smalldatetime, CONVERT(varchar(8), SFORDFIL_SQL.start_dt)) AS start_dt " & _
"FROM SFORDFIL_SQL INNER JOIN IMITMIDX_SQL ON SFORDFIL_SQL.item_no = IMITMIDX_SQL.item_no " & _
"WHERE (SFORDFIL_SQL.due_dt <> 0) AND (SFORDFIL_SQL.start_dt <> 0) AND (SFORDFIL_SQL.ord_status <> 'C')"
Dim myadapter As SqlDataAdapter = New SqlDataAdapter(stSql, con)
Try
myadapter.Fill(myds, "HeaderTable")
grdOrderHeader.DataSource = myds.Tables("HeaderTable")
FormatGridStyle(grdOrderHeader)
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & vbCrLf & "Check the integrity of the data in SFORDFIL_SQL.")
'Exit Sub
End Try [/qote]
The columns have been predefined in the grid with the autosize and all set to things like columnheader. When I pre-define them like this the columns are no longer sizeable by the user at runtime.
I am new to vb.net. Used vb6 for YEARS just cant seem to figure this one out after Days of searching the web.
Thanks
Andy Baldwin
"Testing is the most overlooked programming language on the books!"
Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.