Home All Groups Group Topic Archive Search About

Set a text in a RowHeader cell

Author
25 Feb 2006 7:54 PM
MSNews
Hi.

I need to set texts to the row headers of a Datagridview, like we can do with column headers.

For example:

========================================
      | COLUMN A | COLUMN B | COLUMN B |
ROW 1 |          |          |          |
ROW 2 |          |          |          |
etc..
========================================
I need to set the Row 1, Row 2, etc, to each row header.

I tryed:
DataGridView1.Rows(i).HeaderCell.Value = "some text"
.... but did not works. No text is displayed

The reason I need to use row header is because I want to enjoy
the header behavior (it automatically changes appearance
on mouse mouse, marks the selected row, etc).

There is some manner to set the text?


Cesar

Author
26 Feb 2006 9:37 PM
Homer J Simpson
"MSNews" <info(a)carsoftnet.com.br> wrote in message
news:uNVnyWkOGHA.3856@TK2MSFTNGP12.phx.gbl...
Hi.

I need to set texts to the row headers of a Datagridview, like we can do
with column headers.

For example:

========================================
      | COLUMN A | COLUMN B | COLUMN B |
ROW 1 |          |          |          |
ROW 2 |          |          |          |
etc..
========================================
I need to set the Row 1, Row 2, etc, to each row header.

I tryed:
DataGridView1.Rows(i).HeaderCell.Value = "some text"
.... but did not works. No text is displayed

The reason I need to use row header is because I want to enjoy
the header behavior (it automatically changes appearance
on mouse mouse, marks the selected row, etc).

There is some manner to set the text?

Cesar

' Create a new datagridView control.

datagridView1.Bounds = New Rectangle(New Point(20, 40), New Size(400, 160))

datagridView1.Columns.Add("FED", "FOD")

datagridView1.Rows.Add()

datagridView1.Rows(0).Cells(0).Value = "FOO"

datagridView1.Rows(0).HeaderCell.Value = "SOP"

Me.Controls.Add(datagridView1)
Author
27 Feb 2006 6:18 PM
ronchese
Hmm I got the point.

We must to use a data-unbound grid to can change the header cell.

Thanks.

Cesar


"Homer J Simpson" <nob***@nowhere.com> wrote in message
news:bcpMf.5394$Cp4.4488@edtnps90...
Show quoteHide quote
>
> "MSNews" <info(a)carsoftnet.com.br> wrote in message
> news:uNVnyWkOGHA.3856@TK2MSFTNGP12.phx.gbl...
> Hi.
>
> I need to set texts to the row headers of a Datagridview, like we can do
> with column headers.
>
> For example:
>
> ========================================
>      | COLUMN A | COLUMN B | COLUMN B |
> ROW 1 |          |          |          |
> ROW 2 |          |          |          |
> etc..
> ========================================
> I need to set the Row 1, Row 2, etc, to each row header.
>
> I tryed:
> DataGridView1.Rows(i).HeaderCell.Value = "some text"
> ... but did not works. No text is displayed
>
> The reason I need to use row header is because I want to enjoy
> the header behavior (it automatically changes appearance
> on mouse mouse, marks the selected row, etc).
>
> There is some manner to set the text?
>
> Cesar
>
> ' Create a new datagridView control.
>
> datagridView1.Bounds = New Rectangle(New Point(20, 40), New Size(400,
> 160))
>
> datagridView1.Columns.Add("FED", "FOD")
>
> datagridView1.Rows.Add()
>
> datagridView1.Rows(0).Cells(0).Value = "FOO"
>
> datagridView1.Rows(0).HeaderCell.Value = "SOP"
>
> Me.Controls.Add(datagridView1)
>
>
>
>
Author
7 Apr 2006 9:37 PM
Ofer
Can you also tell how to set the width of this column? so whatever text you
put there will be visible?


Show quoteHide quote
"Homer J Simpson" wrote:

>
> "MSNews" <info(a)carsoftnet.com.br> wrote in message
> news:uNVnyWkOGHA.3856@TK2MSFTNGP12.phx.gbl...
> Hi.
>
> I need to set texts to the row headers of a Datagridview, like we can do
> with column headers.
>
> For example:
>
> ========================================
>       | COLUMN A | COLUMN B | COLUMN B |
> ROW 1 |          |          |          |
> ROW 2 |          |          |          |
> etc..
> ========================================
> I need to set the Row 1, Row 2, etc, to each row header.
>
> I tryed:
> DataGridView1.Rows(i).HeaderCell.Value = "some text"
> .... but did not works. No text is displayed
>
> The reason I need to use row header is because I want to enjoy
> the header behavior (it automatically changes appearance
> on mouse mouse, marks the selected row, etc).
>
> There is some manner to set the text?
>
> Cesar
>
> ' Create a new datagridView control.
>
> datagridView1.Bounds = New Rectangle(New Point(20, 40), New Size(400, 160))
>
> datagridView1.Columns.Add("FED", "FOD")
>
> datagridView1.Rows.Add()
>
> datagridView1.Rows(0).Cells(0).Value = "FOO"
>
> datagridView1.Rows(0).HeaderCell.Value = "SOP"
>
> Me.Controls.Add(datagridView1)
>
>
>
>
>
Author
9 Apr 2006 12:26 AM
Homer J Simpson
"Ofer" <O***@discussions.microsoft.com> wrote in message
news:0ED8BD98-09BE-45FF-82A5-401EF33FF43C@microsoft.com...

> Can you also tell how to set the width of this column? so whatever text
> you
> put there will be visible?

Set the width to -1 or -2 and it will fit the data or the title.
Author
10 Apr 2006 1:10 PM
Ofer
Width of what?
The closest thing was
this.dataGridView1.Rows[0].HeaderCell.OwningColumn.Width but
this.dataGridView1.Rows[0].HeaderCell.OwningColumn is null
I can't figure out the column of the headercells
Column[-1] is an error!


Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Ofer" <O***@discussions.microsoft.com> wrote in message
> news:0ED8BD98-09BE-45FF-82A5-401EF33FF43C@microsoft.com...
>
> > Can you also tell how to set the width of this column? so whatever text
> > you
> > put there will be visible?
>
> Set the width to -1 or -2 and it will fit the data or the title.
>
>
>
>
Author
10 Apr 2006 6:04 PM
Homer J Simpson
"Ofer" <O***@discussions.microsoft.com> wrote in message
news:BA353305-0FA3-4E66-BE55-2617E07CF4E8@microsoft.com...

> Width of what?
> The closest thing was
> this.dataGridView1.Rows[0].HeaderCell.OwningColumn.Width but
> this.dataGridView1.Rows[0].HeaderCell.OwningColumn is null
> I can't figure out the column of the headercells
> Column[-1] is an error!

See "DataGridView control [Windows Forms], column sizing"

IIRC, it's DataGridView1.Columns(1).Width = -1 (but I coud be wrong)

Also see "How to: Set the Sizing Modes of the Windows Forms DataGridView
Control "
Author
10 Apr 2006 6:21 PM
Ofer
DataGridView1.Columns(1) is the second "Real" column in the grid!

I want to reference the grey column before it (-1) where you told the guy to
use
HeaderCell.Value
I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
it does not reference this column.

Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Ofer" <O***@discussions.microsoft.com> wrote in message
> news:BA353305-0FA3-4E66-BE55-2617E07CF4E8@microsoft.com...
>
> > Width of what?
> > The closest thing was
> > this.dataGridView1.Rows[0].HeaderCell.OwningColumn.Width but
> > this.dataGridView1.Rows[0].HeaderCell.OwningColumn is null
> > I can't figure out the column of the headercells
> > Column[-1] is an error!
>
> See "DataGridView control [Windows Forms], column sizing"
>
> IIRC, it's DataGridView1.Columns(1).Width = -1 (but I coud be wrong)
>
> Also see "How to: Set the Sizing Modes of the Windows Forms DataGridView
> Control "
>
>
>
>
Author
10 Apr 2006 7:19 PM
Homer J Simpson
"Ofer" <O***@discussions.microsoft.com> wrote in message
news:160DFE33-A103-4C0F-94A0-10AB3F808507@microsoft.com...

> I want to reference the grey column before it (-1) where you told the guy
> to
> use
> HeaderCell.Value
> I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
> it does not reference this column.

Did you try

DataGridView1.RowHeadersWidthSizeMode = AutoSizeToAllHeaders
Author
10 Apr 2006 7:29 PM
Ofer
Yes! that did it!
Thank you!

Show quoteHide quote
"Homer J Simpson" wrote:

>
> "Ofer" <O***@discussions.microsoft.com> wrote in message
> news:160DFE33-A103-4C0F-94A0-10AB3F808507@microsoft.com...
>
> > I want to reference the grey column before it (-1) where you told the guy
> > to
> > use
> > HeaderCell.Value
> > I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
> > it does not reference this column.
>
> Did you try
>
> DataGridView1.RowHeadersWidthSizeMode = AutoSizeToAllHeaders
>
>
>
>