Subheaders in Datagrid? | | |
Hi all,
Is it possible to create subheaders in datagrids? Or rather to add a parent
header row to an existing datagrid? Currently my DG looks like this:
NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2
whereas id like it to look like:
NAME | A | B |
|PART1 | PART2 | PART3| PART1 | PART2|
or
| A | B
|
NAME |PART1 | PART2 | PART3| PART1 | PART2|
Im trying to intercept the databind event and checking for item type =
header, but am getting a bit stuck after that. IS that the correct approach,
or is there another way?
Thanks!
Spammy | | | | re: Subheaders in Datagrid?
Something like this will work:
Private Sub GrdName_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles GrdName.PreRender
'Add header to datagrid
Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
Dim mycell As New TableCell
mycell.Text = ""
mycell.BackColor = Color.White
dgitem.Cells.Add(mycell)
GrdName.Controls(0).Controls.AddAt(0, dgitem)
End Sub
-John Oakes
"spammy" <me@privacy.net> wrote in message
news:2ir6o6Fqi14eU1@uni-berlin.de...[color=blue]
> Hi all,
>
> Is it possible to create subheaders in datagrids? Or rather to add a[/color]
parent[color=blue]
> header row to an existing datagrid? Currently my DG looks like this:
>
> NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2
>
> whereas id like it to look like:
>
> NAME | A | B |
> |PART1 | PART2 | PART3| PART1 | PART2|
>
> or
>
> | A | B
> |
> NAME |PART1 | PART2 | PART3| PART1 | PART2|
>
> Im trying to intercept the databind event and checking for item type =
> header, but am getting a bit stuck after that. IS that the correct[/color]
approach,[color=blue]
> or is there another way?
>
> Thanks!
>
> Spammy
>
>[/color] | | | | re: Subheaders in Datagrid?
john,
that worked great - thanks!
a few things - tablecell.columnspan allows you to set how "wide" the header
row will be and it may be a better idea to use the tableheadercell rather
than the normal tablecell.
spammy
"John Oakes" <john@nospam.networkproductions.net> wrote in message
news:OAEttOvTEHA.3180@TK2MSFTNGP11.phx.gbl...[color=blue]
> Something like this will work:
>
> Private Sub GrdName_PreRender(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles GrdName.PreRender
> 'Add header to datagrid
> Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
> Dim mycell As New TableCell
> mycell.Text = ""
> mycell.BackColor = Color.White
> dgitem.Cells.Add(mycell)
> GrdName.Controls(0).Controls.AddAt(0, dgitem)
> End Sub
>
> -John Oakes
>
> "spammy" <me@privacy.net> wrote in message
> news:2ir6o6Fqi14eU1@uni-berlin.de...[color=green]
> > Hi all,
> >
> > Is it possible to create subheaders in datagrids? Or rather to add a[/color]
> parent[color=green]
> > header row to an existing datagrid? Currently my DG looks like this:
> >
> > NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2
> >
> > whereas id like it to look like:
> >
> > NAME | A | B[/color][/color]
|[color=blue][color=green]
> > |PART1 | PART2 | PART3| PART1 | PART2|
> >
> > or
> >
> > | A | B
> > |
> > NAME |PART1 | PART2 | PART3| PART1 | PART2|
> >
> > Im trying to intercept the databind event and checking for item type =
> > header, but am getting a bit stuck after that. IS that the correct[/color]
> approach,[color=green]
> > or is there another way?
> >
> > Thanks!
> >
> > Spammy
> >
> >[/color]
>
>[/color] | | | | re: Subheaders in Datagrid?
Thanks. I do use columnspan and tableheadercell depending on the situation.
I was just giving a very simple example for demonstration purposes. Glad it
helped!
-John Oakes
"spammy" <me@privacy.net> wrote in message
news:2irf2hFqr4h6U1@uni-berlin.de...[color=blue]
> john,
>
> that worked great - thanks!
>
> a few things - tablecell.columnspan allows you to set how "wide" the[/color]
header[color=blue]
> row will be and it may be a better idea to use the tableheadercell rather
> than the normal tablecell.
>
> spammy
>
> "John Oakes" <john@nospam.networkproductions.net> wrote in message
> news:OAEttOvTEHA.3180@TK2MSFTNGP11.phx.gbl...[color=green]
> > Something like this will work:
> >
> > Private Sub GrdName_PreRender(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles GrdName.PreRender
> > 'Add header to datagrid
> > Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
> > Dim mycell As New TableCell
> > mycell.Text = ""
> > mycell.BackColor = Color.White
> > dgitem.Cells.Add(mycell)
> > GrdName.Controls(0).Controls.AddAt(0, dgitem)
> > End Sub
> >
> > -John Oakes
> >
> > "spammy" <me@privacy.net> wrote in message
> > news:2ir6o6Fqi14eU1@uni-berlin.de...[color=darkred]
> > > Hi all,
> > >
> > > Is it possible to create subheaders in datagrids? Or rather to add a[/color]
> > parent[color=darkred]
> > > header row to an existing datagrid? Currently my DG looks like this:
> > >
> > > NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2
> > >
> > > whereas id like it to look like:
> > >
> > > NAME | A | B[/color][/color]
> |[color=green][color=darkred]
> > > |PART1 | PART2 | PART3| PART1 | PART2|
> > >
> > > or
> > >
> > > | A | B
> > > |
> > > NAME |PART1 | PART2 | PART3| PART1 | PART2|
> > >
> > > Im trying to intercept the databind event and checking for item type =
> > > header, but am getting a bit stuck after that. IS that the correct[/color]
> > approach,[color=darkred]
> > > or is there another way?
> > >
> > > Thanks!
> > >
> > > Spammy
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Subheaders in Datagrid?
oh - i posted that for group archive purposes just in case anyone else did a
search. i didnt doubt that you knew what what going on!
Spammy
"John Oakes" <john@nospam.networkproductions.net> wrote in message
news:eiO1Es7TEHA.2580@TK2MSFTNGP12.phx.gbl...[color=blue]
> Thanks. I do use columnspan and tableheadercell depending on the[/color]
situation.[color=blue]
> I was just giving a very simple example for demonstration purposes. Glad[/color]
it[color=blue]
> helped!
>
> -John Oakes
>
> "spammy" <me@privacy.net> wrote in message
> news:2irf2hFqr4h6U1@uni-berlin.de...[color=green]
> > john,
> >
> > that worked great - thanks!
> >
> > a few things - tablecell.columnspan allows you to set how "wide" the[/color]
> header[color=green]
> > row will be and it may be a better idea to use the tableheadercell[/color][/color]
rather[color=blue][color=green]
> > than the normal tablecell.
> >
> > spammy
> >
> > "John Oakes" <john@nospam.networkproductions.net> wrote in message
> > news:OAEttOvTEHA.3180@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > Something like this will work:
> > >
> > > Private Sub GrdName_PreRender(ByVal sender As Object, ByVal e As
> > > System.EventArgs) Handles GrdName.PreRender
> > > 'Add header to datagrid
> > > Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
> > > Dim mycell As New TableCell
> > > mycell.Text = ""
> > > mycell.BackColor = Color.White
> > > dgitem.Cells.Add(mycell)
> > > GrdName.Controls(0).Controls.AddAt(0, dgitem)
> > > End Sub
> > >
> > > -John Oakes
> > >
> > > "spammy" <me@privacy.net> wrote in message
> > > news:2ir6o6Fqi14eU1@uni-berlin.de...
> > > > Hi all,
> > > >
> > > > Is it possible to create subheaders in datagrids? Or rather to add a
> > > parent
> > > > header row to an existing datagrid? Currently my DG looks like this:
> > > >
> > > > NAME | A - PART1 | A - PART2 | A - PART3 | B - PART1 | B - PART2
> > > >
> > > > whereas id like it to look like:
> > > >
> > > > NAME | A | B[/color]
> > |[color=darkred]
> > > > |PART1 | PART2 | PART3| PART1 | PART2|
> > > >
> > > > or
> > > >
> > > > | A | B
> > > > |
> > > > NAME |PART1 | PART2 | PART3| PART1 | PART2|
> > > >
> > > > Im trying to intercept the databind event and checking for item type[/color][/color][/color]
=[color=blue][color=green][color=darkred]
> > > > header, but am getting a bit stuck after that. IS that the correct
> > > approach,
> > > > or is there another way?
> > > >
> > > > Thanks!
> > > >
> > > > Spammy
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,295 network members.
|