|
-
Jan 25th, 2005, 05:13 PM
#1
Thread Starter
Lively Member
Help setting datagrid properties
Hi all, I hope you guys can help me with this issue.
i am creating a windows form and cannot set the properties for the colums.
e.g changing the colum name and alternating background color. I have attached some of the code to see if anyone may help me or tell me what I am doing wrong. The form doesnt give me any error but it does not change the property either.
Thanks in advance.
Private Function mainconn()
Dim checkcon As String
objconnection.Open()
a.SelectCommand = New OleDbCommand
a.SelectCommand.Connection = objconnection
'Selects the ID, Name, LastName etc fields on the table
a.SelectCommand.CommandText = _
" SELECT * from financial order by timein"
a.SelectCommand.CommandType = CommandType.Text
a.SelectCommand.ExecuteNonQuery()
a.Fill(ds, "financial")
objconnection.Close()
a = Nothing
objconnection = Nothing
'grid
DataGrid1.DataSource = ds
DataGrid1.DataMember = "financial"
DataGrid1.ColumnHeadersVisible = True
'declaring objects
Dim datagridtablestyle As New DataGridTableStyle
Dim columnstyle As New DataGridTextBoxColumn
'alternating color
datagridtablestyle.AlternatingBackColor = Color.WhiteSmoke
datagridtablestyle.MappingName = "Financial"
columnstyle.MappingName = "ID"
columnstyle.HeaderText = "Test ID"
'same settings for the rest of the fields
datagridtablestyle.GridColumnStyles.Add(columnstyle)
DataGrid1.TableStyles.Add(datagridtablestyle)
End Function
-
Jan 27th, 2005, 12:47 AM
#2
Sleep mode
Not very sure why but DG may need to be refreshed and get replaced in the Form collection's object .
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
|