473,773 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5965
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.co m> 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_PreRe nder _
(ByVal sender As Object, _
ByVal e As System.EventArg s) _
Handles DataGrid1.PreRe nder
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.co m> wrote in message
news:ug******** ******@TK2MSFTN GP14.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.co m> wrote in message
news:ug******** ******@TK2MSFTN GP14.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******** ******@TK2MSFTN GP15.phx.gbl...
Hi Gary,

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

Private Sub DataGrid1_PreRe nder _
(ByVal sender As Object, _
ByVal e As System.EventArg s) _
Handles DataGrid1.PreRe nder
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.co m> wrote in message
news:ug******** ******@TK2MSFTN GP14.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
1255
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 next matching row. I would love a syntax where it can accept wildcards, i.e. search item name for '%red%' to search for anything that has the word 'red' anywhere within it. So far my only solution was to create a new DataView for each search...
5
8800
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
1244
by: Roger | last post by:
How do I dynamically set the column header in a datagrid based on a sql query?
3
1487
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 in some way which columns are not editable, I have the columns I would like to lock for editing, but how do I tell the datagrid this ? My columns are dynamically added to the grid at runtime, because the dataset might be different everytime Any...
1
1201
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 information in one column. The header is now called General Information, I'd like to add an Edit, linked to another page referencing the selected record's ID from a request. And because it is a templatecolumn, I cannot use the built-in edit with DataGrid. ...
3
1572
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 As New TableCell()
4
2300
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 datagrid. I'm using the CommandEvent to do some stuff. When I try to use syntax like this: e.Item(1).FindControl("txtQuestion"), TextBox).Text
1
1341
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 of SendMessage API (lParam can't be of type RECT):
1
890
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
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.