|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Set a text in a RowHeader cellI 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 "MSNews" <info(a)carsoftnet.com.br> wrote in message I need to set texts to the row headers of a Datagridview, like we can do news:uNVnyWkOGHA.3856@TK2MSFTNGP12.phx.gbl... Hi. 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) 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) > > > > 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) > > > > > "Ofer" <O***@discussions.microsoft.com> wrote in message Set the width to -1 or -2 and it will fit the data or the title.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? 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. > > > > "Ofer" <O***@discussions.microsoft.com> wrote in message See "DataGridView control [Windows Forms], column sizing"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! 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 " 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 " > > > > "Ofer" <O***@discussions.microsoft.com> wrote in message Did you trynews: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. DataGridView1.RowHeadersWidthSizeMode = AutoSizeToAllHeaders 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 > > > >
How to invoke IE ...
2003 v. 2005 studio - need some help, please. Raising CustomControl Events from within Class How to connect to MS Access.... X & Y within DataGridView at run time database connection Moving a project to a different location Using 'Function Keys' In vb.net Newbie... Binary Formatter not suitable accross firewalls |
|||||||||||||||||||||||