Set a text in a RowHeader cell

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MSNews

    Set a text in a RowHeader cell

    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.R ows(i).HeaderCe ll.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

  • Homer J Simpson

    #2
    Re: Set a text in a RowHeader cell


    "MSNews" <info(a)carsoft net.com.br> wrote in message
    news:uNVnyWkOGH A.3856@TK2MSFTN GP12.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.R ows(i).HeaderCe ll.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.B ounds = New Rectangle(New Point(20, 40), New Size(400, 160))

    datagridView1.C olumns.Add("FED ", "FOD")

    datagridView1.R ows.Add()

    datagridView1.R ows(0).Cells(0) .Value = "FOO"

    datagridView1.R ows(0).HeaderCe ll.Value = "SOP"

    Me.Controls.Add (datagridView1)




    Comment

    • ronchese

      #3
      Re: Set a text in a RowHeader cell

      Hmm I got the point.

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

      Thanks.

      Cesar


      "Homer J Simpson" <nobody@nowhere .com> wrote in message
      news:bcpMf.5394 $Cp4.4488@edtnp s90...[color=blue]
      >
      > "MSNews" <info(a)carsoft net.com.br> wrote in message
      > news:uNVnyWkOGH A.3856@TK2MSFTN GP12.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.R ows(i).HeaderCe ll.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.B ounds = New Rectangle(New Point(20, 40), New Size(400,
      > 160))
      >
      > datagridView1.C olumns.Add("FED ", "FOD")
      >
      > datagridView1.R ows.Add()
      >
      > datagridView1.R ows(0).Cells(0) .Value = "FOO"
      >
      > datagridView1.R ows(0).HeaderCe ll.Value = "SOP"
      >
      > Me.Controls.Add (datagridView1)
      >
      >
      >
      >[/color]


      Comment

      • saravanan_article
        New Member
        • Mar 2006
        • 2

        #4
        Originally posted by 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" <nobody@nowhere .com> wrote in message
        news:bcpMf.5394 $Cp4.4488@edtnp s90...[color=blue]
        >
        > "MSNews" <info(a)carsoft net.com.br> wrote in message
        > news:uNVnyWkOGH A.3856@TK2MSFTN GP12.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.R ows(i).HeaderCe ll.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.B ounds = New Rectangle(New Point(20, 40), New Size(400,
        > 160))
        >
        > datagridView1.C olumns.Add("FED ", "FOD")
        >
        > datagridView1.R ows.Add()
        >
        > datagridView1.R ows(0).Cells(0) .Value = "FOO"
        >
        > datagridView1.R ows(0).HeaderCe ll.Value = "SOP"
        >
        > Me.Controls.Add (datagridView1)
        >
        >
        >
        >[/color]

        Hi

        What is datagridview..
        I want to display a text in rowheaders of DataGrid in C# not in GridView.. Please Give some ideas how to do that?

        Comment

        • Ofer

          #5
          Re: Set a text in a RowHeader cell

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


          "Homer J Simpson" wrote:
          [color=blue]
          >
          > "MSNews" <info(a)carsoft net.com.br> wrote in message
          > news:uNVnyWkOGH A.3856@TK2MSFTN GP12.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.R ows(i).HeaderCe ll.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.B ounds = New Rectangle(New Point(20, 40), New Size(400, 160))
          >
          > datagridView1.C olumns.Add("FED ", "FOD")
          >
          > datagridView1.R ows.Add()
          >
          > datagridView1.R ows(0).Cells(0) .Value = "FOO"
          >
          > datagridView1.R ows(0).HeaderCe ll.Value = "SOP"
          >
          > Me.Controls.Add (datagridView1)
          >
          >
          >
          >
          >[/color]

          Comment

          • Homer J Simpson

            #6
            Re: Set a text in a RowHeader cell


            "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
            news:0ED8BD98-09BE-45FF-82A5-401EF33FF43C@mi crosoft.com...
            [color=blue]
            > Can you also tell how to set the width of this column? so whatever text
            > you
            > put there will be visible?[/color]

            Set the width to -1 or -2 and it will fit the data or the title.



            Comment

            • Ofer

              #7
              Re: Set a text in a RowHeader cell

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


              "Homer J Simpson" wrote:
              [color=blue]
              >
              > "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
              > news:0ED8BD98-09BE-45FF-82A5-401EF33FF43C@mi crosoft.com...
              >[color=green]
              > > Can you also tell how to set the width of this column? so whatever text
              > > you
              > > put there will be visible?[/color]
              >
              > Set the width to -1 or -2 and it will fit the data or the title.
              >
              >
              >
              >[/color]

              Comment

              • Homer J Simpson

                #8
                Re: Set a text in a RowHeader cell


                "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
                news:BA353305-0FA3-4E66-BE55-2617E07CF4E8@mi crosoft.com...
                [color=blue]
                > Width of what?
                > The closest thing was
                > this.dataGridVi ew1.Rows[0].HeaderCell.Own ingColumn.Width but
                > this.dataGridVi ew1.Rows[0].HeaderCell.Own ingColumn is null
                > I can't figure out the column of the headercells
                > Column[-1] is an error![/color]

                See "DataGridVi ew control [Windows Forms], column sizing"

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

                Also see "How to: Set the Sizing Modes of the Windows Forms DataGridView
                Control "



                Comment

                • Ofer

                  #9
                  Re: Set a text in a RowHeader cell

                  DataGridView1.C olumns(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.Valu e
                  I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
                  it does not reference this column.

                  "Homer J Simpson" wrote:
                  [color=blue]
                  >
                  > "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
                  > news:BA353305-0FA3-4E66-BE55-2617E07CF4E8@mi crosoft.com...
                  >[color=green]
                  > > Width of what?
                  > > The closest thing was
                  > > this.dataGridVi ew1.Rows[0].HeaderCell.Own ingColumn.Width but
                  > > this.dataGridVi ew1.Rows[0].HeaderCell.Own ingColumn is null
                  > > I can't figure out the column of the headercells
                  > > Column[-1] is an error![/color]
                  >
                  > See "DataGridVi ew control [Windows Forms], column sizing"
                  >
                  > IIRC, it's DataGridView1.C olumns(1).Width = -1 (but I coud be wrong)
                  >
                  > Also see "How to: Set the Sizing Modes of the Windows Forms DataGridView
                  > Control "
                  >
                  >
                  >
                  >[/color]

                  Comment

                  • Homer J Simpson

                    #10
                    Re: Set a text in a RowHeader cell


                    "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
                    news:160DFE33-A103-4C0F-94A0-10AB3F808507@mi crosoft.com...
                    [color=blue]
                    > I want to reference the grey column before it (-1) where you told the guy
                    > to
                    > use
                    > HeaderCell.Valu e
                    > I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
                    > it does not reference this column.[/color]

                    Did you try

                    DataGridView1.R owHeadersWidthS izeMode = AutoSizeToAllHe aders



                    Comment

                    • Ofer

                      #11
                      Re: Set a text in a RowHeader cell

                      Yes! that did it!
                      Thank you!

                      "Homer J Simpson" wrote:
                      [color=blue]
                      >
                      > "Ofer" <Ofer@discussio ns.microsoft.co m> wrote in message
                      > news:160DFE33-A103-4C0F-94A0-10AB3F808507@mi crosoft.com...
                      >[color=green]
                      > > I want to reference the grey column before it (-1) where you told the guy
                      > > to
                      > > use
                      > > HeaderCell.Valu e
                      > > I looked in the Set the Sizing Modes of the Windows Forms DataGridView but
                      > > it does not reference this column.[/color]
                      >
                      > Did you try
                      >
                      > DataGridView1.R owHeadersWidthS izeMode = AutoSizeToAllHe aders
                      >
                      >
                      >
                      >[/color]

                      Comment

                      Working...