473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

finding the header item in a datagrid

The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as a
heading section, a footer section, or a data row." So, it must be possible
to access it.

Anyone know how?
Thanks,
Gary
Nov 18 '05 #1
5 5946
You may be able to get at them in more places, but I've always used the
ItemCreated event that gets triggered as the grid gets built. You can
check the type of item (header, footer...) that is being created and
modify it before it gets placed.

Have A Better One!

John M Deal, MCP
Necessity Software

GaryB wrote:
The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as a
heading section, a footer section, or a data row." So, it must be possible
to access it.

Anyone know how?
Thanks,
Gary

Nov 18 '05 #2
Hi GaryB:

Yes, tis true. The Items collection only contains data bound items,
but the Controls collection will contain everything.

You can assume Controls[0] will have the DataGridItem for the header,
and Controls[Controls.Length - 1] will have the DataGridItem for the
footer.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 10 Nov 2004 17:32:58 -0800, "GaryB" <gb@nospam.com> wrote:
The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as a
heading section, a footer section, or a data row." So, it must be possible
to access it.

Anyone know how?
Thanks,
Gary


Nov 18 '05 #3
Hi Gary,

If you walk the Controls collection far enough you can get it as a table
cell.

Private Sub DataGrid1_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles DataGrid1.PreRender
Dim dgCell As TableCell
dgCell = CType(DataGrid1.Controls(0). _
Controls(0). _
Controls(0), _
TableCell)
dgCell.Text = "Hey look here!"
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]

"GaryB" <gb@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as a
heading section, a footer section, or a data row." So, it must be
possible to access it.

Anyone know how?
Thanks,
Gary


Nov 18 '05 #4
I had the same problem. Those docs are bogus. The items collection only
has the data rows. If you want to access header fields you need to use the
columns collection. For instance to see how a column is justified you would
say...
if myGrid.columns(i).HeaderStyle.HorizontalAlign = HorizontalAlign.right
then....

to see how a column is aligned.
T
"GaryB" <gb@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as a
heading section, a footer section, or a data row." So, it must be
possible to access it.

Anyone know how?
Thanks,
Gary

Nov 18 '05 #5
I finally found that the HeaderText is in the columns collection as Tina
indicated. I had used that before but the bogus docs had me looking
elsewhere.
Gary

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:eu**************@TK2MSFTNGP15.phx.gbl...
Hi Gary,

If you walk the Controls collection far enough you can get it as a table
cell.

Private Sub DataGrid1_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles DataGrid1.PreRender
Dim dgCell As TableCell
dgCell = CType(DataGrid1.Controls(0). _
Controls(0). _
Controls(0), _
TableCell)
dgCell.Text = "Hey look here!"
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]

"GaryB" <gb@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
The datagrid.items collection only appears to have data rows in it. for
Instance...
dim myItem ad dataGridItem
myItem = myGrid.Items(0)

returns the first data row of data.

How can I access the Headertext and footer text? The docs say ...

" A DataGridItem represents an item (row) in a DataGrid control, such as
a heading section, a footer section, or a data row." So, it must be
possible to access it.

Anyone know how?
Thanks,
Gary

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MrNobody | last post by:
what I'd like to have is a simple feature to search within a column in a DataGrid and have that the first matching row selected, then the user can choose to search again where it will select the...
5
by: Alex K. | last post by:
How do I define multiline column header in DataGrid control? I need two-line headers for some columns. Thank you
1
by: Roger | last post by:
How do I dynamically set the column header in a datagrid based on a sql query?
3
by: CJ Smit | last post by:
Hi Guys I have a datagrid that are databound at runtime and columns are added automatically to it from the dataset. OnEdit Command renders all fields as editable, my problem is I need to specify...
1
by: David Lozzi | last post by:
Hi, I'd like to customize a header in a DataGrid. I want to add a link in the header, as well as pull a recordset's ID. I am using a TemplateColumn so that I can hold several lines of...
3
by: AMD Desktop | last post by:
Hi, I need to add a header to a datagrid. This is the code I am trying to use: Dim dgStaffingReport As New DataGrid Dim dgitem As New DataGridItem(0, 0, ListItemType.Header) Dim mycell...
4
by: Chris | last post by:
Using: DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand is there a way to find a specific item in the...
1
by: Simon Abolnar | last post by:
I am using VB.NET 2003 Framework 1.1 I can't get header item rectangle of ListView. HeaderItemHandle = SendMessage (HWnd, HDM_GETITEMRECT, i, headerItemRectangle) Problem is in declaration...
1
by: reidarT | last post by:
I have 2 datagrids When I select a line in datagrid one, the second datagrid is filled. How do I hide the header in datagrid two until it is filled reidarT
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.