Am I going Mad?

  • Thread starter Thread starter Wizard
  • Start date Start date
W

Wizard

Hi,

I have a form and I want to format the Datagrid on it. I have the following
code but it just won`t format. Anybody any Ideas Why? Sorry you will have to
be simple about it as im a Newbie.

Here is my code:

Private Sub frmSystemUsers_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
'File Datasets
Try
dsSystemUsers.EnforceConstraints = False
Try
Me.odcSystemUsers.Open()
odaSystemUsers.Fill(dsSystemUsers)
mlLoading = True
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcSystemUsers.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
Finally
mlLoading = False
End Try
'End of Fill Datasets

'Format DataTable
Dim aGridTableStyle As New DataGridTableStyle
aGridTableStyle.MappingName = "SystemUsers"

Dim aUserName As New DataGridTextBoxColumn
Dim aFirstName As New DataGridTextBoxColumn
Dim aSurname As New DataGridTextBoxColumn

With aUserName
.MappingName = "Users_Name"
.HeaderText = "UserName"
.Width = 30
End With

With aFirstName
.MappingName = "User_First"
.HeaderText = "First Name"
.Width = 65
End With

With aSurname
.MappingName = "User_Last"
.HeaderText = "Surname"
.Width = 50
End With

With aGridTableStyle.GridColumnStyles
.Add(aUserName)
.Add(aFirstName)
.Add(aSurname)
End With

dgdSystemUsers.TableStyles.Add(aGridTableStyle)

If dsSystemUsers.Tables(0).Rows.Count > 0 Then
With dgdSystemUsers
.DataSource = dsSystemUsers.Tables(0)
.Expand(-1)
.NavigateTo(0, "UserName")
End With
End If
End Sub

Many Thanks
Wiz
 
The first thing that I'd check is whether the mapping name is right. Is the
name of dsSystemUsers.Tables(0) really "SystemUsers"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top