Problem with DataGrid Formatting

N

Newbie!

Hi Group,

I`ve wrotesome code to format a datagrid with only the coloums I need.
However it won`t automatically open up my table format, It give me the
little + button, i click on that and its ok, how do i get it to
automatically open?

Ta
Si

I have the following code on my project:

Private Sub tbrMainMenu_ButtonClick(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbrMainMenu.ButtonClick
Select Case True
Case e.Button Is Me.tbbPasswordLists
tpgExcellence.Visible = False
tpgPasswordLists.Visible = True
End Select

'Password Lists Table Mapping Start
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapPasswordLists"

Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()

With aCol1
.MappingName = "System"
.HeaderText = "System"
.Width = 20
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With

With aCol2
.MappingName = "Username"
.HeaderText = "Username"
.Width = 110
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With

With aCol3
.MappingName = "WebAddress"
.HeaderText = "WebAddress"
.Width = 110
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = True
End With

With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)

aGridTableStyle.MappingName = dsPasswordLists.Tables(0).TableName
End With

odaPasswordLists.Fill(dsPasswordLists)
dgdPasswordLists.TableStyles.Add(aGridTableStyle)

If dsPasswordLists.Tables(0).Rows.Count > 0 Then
With dgdPasswordLists
.DataSource = dsPasswordLists.Tables(0)
.Expand(-0)
.NavigateTo(0, "PasswordListMiscellaneous")
End With
End If
 
C

Cor

Hi Newbie,

Can it have to do with this?

Expand = the number of the row to expand. If set to -1, all rows are
expanded.

Cor
 
K

Ken Tucker [MVP]

Hi,

The NavigateTo method will move to a datarelation you have setup.
Which I dont see in your code. I would get rid of the navigateto and expand
lines.

Ken
 
N

Newbie!

Great Stuff it worked!

Cheers Guys
Si

Ken Tucker said:
Hi,

The NavigateTo method will move to a datarelation you have setup.
Which I dont see in your code. I would get rid of the navigateto and expand
lines.

Ken
 

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

Top