Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I was wondering if anyone knows how to insert text or data into the row header of a datagrid? iAny help would be great. Thanks in advnace!:)

 

Topmade

  • Moderators
Posted

something like this...


       Dim dgStyle As New DataGridTableStyle()
       With dgStyle
           .AlternatingBackColor = Color.LightGray
           .BackColor = Color.WhiteSmoke
           .ForeColor = Color.MidnightBlue
           .GridLineColor = Color.Honeydew
           .HeaderBackColor = Color.MidnightBlue
           .HeaderFont = New Font("Arial", 8.0!, FontStyle.Bold)
           .HeaderForeColor = Color.White
           .LinkColor = Color.Teal
           .MappingName = "Appointments"
           .SelectionBackColor = Color.Yellow
           .SelectionForeColor = Color.DarkMagenta
       End With
       Dim grd As New DataGridTextBoxColumn()
       With grd
           .HeaderText = "Some title"
           .MappingName = "myFieldName"
           .Alignment = HorizontalAlignment.Center
           .Width = 45
       End With

       dgStyle.GridColumnStyles.AddRange(New DataGridColumnStyle() {grd})
       DataGrid1.TableStyles.Add(dgStyle)

Visit...Bassic Software
Posted

I still can't get it to work. I'm bindng it to a dataset, does this have anything to do with it? What am I doing wrong?

 

Dim CN As New OleDb.OleDbConnection(strPath)

CN.Open()

'DataAdapter

Dim DA As New OleDb.OleDbDataAdapter _

("Select * from Users ", CN)

'Dataset

Dim DS As New DataSet()

'Fill DataAdapter

DA.Fill(DS, "Users")

'Hide a column

DS.Tables("Users").Columns("UserId").ColumnMapping = MappingType.Hidden

Dim my As New System.Data.DataTable()

 

'Change a column name

'DS.Tables("Users").Rows(1)

DS.Tables("Users").Columns("City").ColumnName = "Expense Type"

 

Dim dgStyle As New DataGridTableStyle()

With dgStyle

.AlternatingBackColor = Color.LightGray

.BackColor = Color.WhiteSmoke

.ForeColor = Color.MidnightBlue

.GridLineColor = Color.Honeydew

.HeaderBackColor = Color.MidnightBlue

.HeaderFont = New Font("Arial", 8.0!, FontStyle.Bold)

.HeaderForeColor = Color.White

.LinkColor = Color.Teal

.MappingName = "UserNamerr"

.SelectionBackColor = Color.Yellow

.SelectionForeColor = Color.DarkMagenta

End With

Dim grd As New DataGridTextBoxColumn()

With grd

.HeaderText = "ydghdgfhdgf"

.MappingName = "UserNamegdh"

.Alignment = HorizontalAlignment.Center

.Width = 45

End With

'Bind data to DataGrid

DataGrid1.SetDataBinding(DS, "Users")

dgStyle.GridColumnStyles.AddRange(New DataGridColumnStyle() {grd})

DataGrid1.TableStyles.Add(dgStyle)

 

Topmade

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...