I am still having troubles. I wonder if it is becuse my data table isn't a
SQL table, but merely one I constucted myself. I guess I need to play with
this some more.
Thanks for the input.
Michael
"EricJ" <ericRé(E-Mail Removed)> wrote in message
news:3fd974f4$0$17573$(E-Mail Removed)...
> i didn't adapt it to your case but this is working here (drgMain is the
> datagrid)
> hope it helps
>
> dsForm = New DataSet("data")
> dsForm = SqlHelper.ExecuteDataset(gstrCnn, CommandType.Text,
strSql)
> Dim ts As New DataGridTableStyle
> ts.MappingName = "Table"
>
> dgrMain.TableStyles.Clear()
>
> dgrMain.SetDataBinding(dsForm, "Table")
>
> dgrMain.TableStyles.Add(ts)
> ts.GridColumnStyles(0).Width = 0
> ts.GridColumnStyles(1).Width = 100
> ts.GridColumnStyles(2).Width = 50
> ts.GridColumnStyles(3).Width = 200
>
> ts.AllowSorting = True
> ts.AlternatingBackColor = Color.Lavender
> ts.BackColor = Color.WhiteSmoke
> ts.ForeColor = Color.MidnightBlue
> ts.GridLineColor = Color.Gainsboro
> ts.HeaderBackColor = Color.MidnightBlue
> ts.HeaderForeColor = Color.WhiteSmoke
> ts.LinkColor = Color.Navy
> ts.SelectionBackColor = Color.Navy
> ts.SelectionForeColor = Color.Lavender
> ts.ColumnHeadersVisible = True
>
> "Michael Hesse" <(E-Mail Removed)> wrote in message
> news:kgcCb.70247$(E-Mail Removed)...
> > This must have been covered a lot of times, but I still cannot seem to
get
> > this work. I have a data table called "dt" and a data grid, "dg". The
> data
> > table is not part of a data set.
> >
> > Here is my code. What am I doing wrong?
> > ______________________________________
> > dg.SetDataBinding(dt, Nothing)
> >
> > Dim dgts As DataGridTableStyle = New DataGridTableStyle
> >
> > dgts.MappingName = "dt"
> >
> > For i As Integer = 1 To 10
> >
> > Dim CStyle As New DataGridTextBoxColumn
> >
> > CStyle.Width = i * 100
> >
> > dgts.GridColumnStyles.Add(CStyle)
> >
> > Next
> >
> > dg.TableStyles.Add(dgts)
> >
> > dg.TableStyles("dt").GridColumnStyles(0).Width = 500
> >
> > dg.TableStyles("dt").GridColumnStyles(1).Width = 2500
> >
> > dg.Refresh()
> >
> > _____________________________________________
> >
> > Thanks for any help.
> >
> >
>
>
|