Dynamic DataGridView missing horizontal scrollbar

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

    #1

    Dynamic DataGridView missing horizontal scrollbar

    Hi,

    I am dynamically creating datagridviews for my application, then
    filling them with data from a 30 row datatable, and everything seems to
    work great with one exception. My horizontal scrollbar never appears --
    no problem with the vertical scrollbar. I even try setting the
    scrollbars property to Both, but still I only see the vertical
    scrollbar.

    Is there any other way to force the DataGridView's vertical scrollbar
    to appear?????

    Thanks,

    Crazy

  • Vijay

    #2
    Re: Dynamic DataGridView missing horizontal scrollbar

    Try selecting the last cell of the grid row... using code... that might help

    Vijay

    "Crazy Cat" <danbredy@hotma il.com> wrote in message
    news:1144095717 .868539.46610@v 46g2000cwv.goog legroups.com...[color=blue]
    > Hi,
    >
    > I am dynamically creating datagridviews for my application, then
    > filling them with data from a 30 row datatable, and everything seems to
    > work great with one exception. My horizontal scrollbar never appears --
    > no problem with the vertical scrollbar. I even try setting the
    > scrollbars property to Both, but still I only see the vertical
    > scrollbar.
    >
    > Is there any other way to force the DataGridView's vertical scrollbar
    > to appear?????
    >
    > Thanks,
    >
    > Crazy
    >[/color]


    Comment

    • Crazy Cat

      #3
      Re: Dynamic DataGridView missing horizontal scrollbar


      Vijay wrote:[color=blue]
      > Try selecting the last cell of the grid row... using code... that might help
      >
      > Vijay
      >
      > "Crazy Cat" <danbredy@hotma il.com> wrote in message
      > news:1144095717 .868539.46610@v 46g2000cwv.goog legroups.com...[color=green]
      > > Hi,
      > >
      > > I am dynamically creating datagridviews for my application, then
      > > filling them with data from a 30 row datatable, and everything seems to
      > > work great with one exception. My horizontal scrollbar never appears --
      > > no problem with the vertical scrollbar. I even try setting the
      > > scrollbars property to Both, but still I only see the vertical
      > > scrollbar.
      > >
      > > Is there any other way to force the DataGridView's vertical scrollbar
      > > to appear?????
      > >
      > > Thanks,
      > >
      > > Crazy
      > >[/color][/color]

      Doesn't work -- I used datagridview.cu rrentrow.cells( INDEX).selected =
      true but no dice.

      Any other ideas?

      Thanks

      Comment

      • Vijay

        #4
        Re: Dynamic DataGridView missing horizontal scrollbar

        uhm.. ok.., And you do have more than the visible area of columns, still not
        getting scrollbars.. are u using 2.0 or 1.1 ?

        VJ

        "Crazy Cat" <danbredy@hotma il.com> wrote in message
        news:1144100910 .018851.77170@i 40g2000cwc.goog legroups.com...[color=blue]
        >
        > Vijay wrote:[color=green]
        >> Try selecting the last cell of the grid row... using code... that might
        >> help
        >>
        >> Vijay
        >>
        >> "Crazy Cat" <danbredy@hotma il.com> wrote in message
        >> news:1144095717 .868539.46610@v 46g2000cwv.goog legroups.com...[color=darkred]
        >> > Hi,
        >> >
        >> > I am dynamically creating datagridviews for my application, then
        >> > filling them with data from a 30 row datatable, and everything seems to
        >> > work great with one exception. My horizontal scrollbar never appears --
        >> > no problem with the vertical scrollbar. I even try setting the
        >> > scrollbars property to Both, but still I only see the vertical
        >> > scrollbar.
        >> >
        >> > Is there any other way to force the DataGridView's vertical scrollbar
        >> > to appear?????
        >> >
        >> > Thanks,
        >> >
        >> > Crazy
        >> >[/color][/color]
        >
        > Doesn't work -- I used datagridview.cu rrentrow.cells( INDEX).selected =
        > true but no dice.
        >
        > Any other ideas?
        >
        > Thanks
        >[/color]


        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Dynamic DataGridView missing horizontal scrollbar

          Crazy,

          With this code I see a vertical and a horizontal scrollbar

          \\\
          Dim mydatagridview As New DataGridView
          Controls.Add(my datagridview)
          mydatagridview. DataSource = MyEmployeesBind ingSource
          ///

          I hope this helps,

          Cor


          Comment

          • Crazy Cat

            #6
            Re: Dynamic DataGridView missing horizontal scrollbar

            I'm pretty sure I'm using 2.0. I do have more than the visible area of
            columns -- almost twice as much.

            Thanks,

            Vijay wrote:[color=blue]
            > uhm.. ok.., And you do have more than the visible area of columns, still not
            > getting scrollbars.. are u using 2.0 or 1.1 ?
            >
            > VJ
            >
            > "Crazy Cat" <danbredy@hotma il.com> wrote in message
            > news:1144100910 .018851.77170@i 40g2000cwc.goog legroups.com...[color=green]
            > >
            > > Vijay wrote:[color=darkred]
            > >> Try selecting the last cell of the grid row... using code... that might
            > >> help
            > >>
            > >> Vijay
            > >>
            > >> "Crazy Cat" <danbredy@hotma il.com> wrote in message
            > >> news:1144095717 .868539.46610@v 46g2000cwv.goog legroups.com...
            > >> > Hi,
            > >> >
            > >> > I am dynamically creating datagridviews for my application, then
            > >> > filling them with data from a 30 row datatable, and everything seems to
            > >> > work great with one exception. My horizontal scrollbar never appears --
            > >> > no problem with the vertical scrollbar. I even try setting the
            > >> > scrollbars property to Both, but still I only see the vertical
            > >> > scrollbar.
            > >> >
            > >> > Is there any other way to force the DataGridView's vertical scrollbar
            > >> > to appear?????
            > >> >
            > >> > Thanks,
            > >> >
            > >> > Crazy
            > >> >[/color]
            > >
            > > Doesn't work -- I used datagridview.cu rrentrow.cells( INDEX).selected =
            > > true but no dice.
            > >
            > > Any other ideas?
            > >
            > > Thanks
            > >[/color][/color]

            Comment

            • Crazy Cat

              #7
              Re: Dynamic DataGridView missing horizontal scrollbar

              I don't have a binding source because I don't use the DataSet designer
              to get the tables back. Perhaps that'll help? I'll take a look and post
              back.

              Thanks,


              Cor Ligthert [MVP] wrote:[color=blue]
              > Crazy,
              >
              > With this code I see a vertical and a horizontal scrollbar
              >
              > \\\
              > Dim mydatagridview As New DataGridView
              > Controls.Add(my datagridview)
              > mydatagridview. DataSource = MyEmployeesBind ingSource
              > ///
              >
              > I hope this helps,
              >
              > Cor[/color]

              Comment

              • Crazy Cat

                #8
                Re: Dynamic DataGridView missing horizontal scrollbar

                OK,

                I tried this again with the Binding Source and still no scrollbar --
                does anyone have any other ideas???? PLEASE???

                Here's the code --


                Dim tabDetails As TabPage
                Dim DetailsBindingS ource As BindingSource
                Dim dgvDetails As DataGridView

                tctlDetails.Tab Pages.Clear()
                If PortDetailsData Set IsNot Nothing Then
                For Each dt As System.Data.Dat aTable In
                PortDetailsData Set.Tables

                Me.tctlDetails. TabPages.Add(dt .Rows(0).Item(" MSC_NAME"))
                tabDetails =
                tctlDetails.Tab Pages(tctlDetai ls.TabPages.Cou nt - 1)
                dgvDetails = New DataGridView()
                With dgvDetails
                .Visible = True
                .AllowUserToAdd Rows = False
                .AllowUserToDel eteRows = False
                DetailsBindingS ource = New
                BindingSource(P ortDetailsDataS et, dt.TableName)
                .DataSource = DetailsBindingS ource
                tabDetails.Cont rols.Add(dgvDet ails)
                dgvDetails.Dock = DockStyle.Fill
                dgvDetails.Scro llBars =
                System.Windows. Forms.ScrollBar s.Both
                For Each a As DataGridViewCol umn In .Columns
                a.ReadOnly = True
                Next
                .ScrollBars = System.Windows. Forms.ScrollBar s.Both
                End With
                Next
                End If

                BTW, on a side note I allow the user to clear the tabs from the
                tabcontrol assuming that because the dynamic bindingsources and
                datatables are no longer referenced the VS garbage collecter will clean
                them up. Is that a correct assumption or should I delete the referenced
                objects myself?

                Thanks,

                Crazy
                Crazy Cat wrote:[color=blue]
                > I don't have a binding source because I don't use the DataSet designer
                > to get the tables back. Perhaps that'll help? I'll take a look and post
                > back.
                >
                > Thanks,
                >
                >
                > Cor Ligthert [MVP] wrote:[color=green]
                > > Crazy,
                > >
                > > With this code I see a vertical and a horizontal scrollbar
                > >
                > > \\\
                > > Dim mydatagridview As New DataGridView
                > > Controls.Add(my datagridview)
                > > mydatagridview. DataSource = MyEmployeesBind ingSource
                > > ///
                > >
                > > I hope this helps,
                > >
                > > Cor[/color][/color]

                Comment

                • Cor Ligthert [MVP]

                  #9
                  Re: Dynamic DataGridView missing horizontal scrollbar

                  Crazy Cat,

                  Because that I see "Dock Fill" are you sure that your DataGridView is narrow
                  enough to show the horizontal scrollbar?

                  Cor

                  "Crazy Cat" <danbredy@hotma il.com> schreef in bericht
                  news:1144265673 .701410.259600@ u72g2000cwu.goo glegroups.com.. .[color=blue]
                  > OK,
                  >
                  > I tried this again with the Binding Source and still no scrollbar --
                  > does anyone have any other ideas???? PLEASE???
                  >
                  > Here's the code --
                  >
                  >
                  > Dim tabDetails As TabPage
                  > Dim DetailsBindingS ource As BindingSource
                  > Dim dgvDetails As DataGridView
                  >
                  > tctlDetails.Tab Pages.Clear()
                  > If PortDetailsData Set IsNot Nothing Then
                  > For Each dt As System.Data.Dat aTable In
                  > PortDetailsData Set.Tables
                  >
                  > Me.tctlDetails. TabPages.Add(dt .Rows(0).Item(" MSC_NAME"))
                  > tabDetails =
                  > tctlDetails.Tab Pages(tctlDetai ls.TabPages.Cou nt - 1)
                  > dgvDetails = New DataGridView()
                  > With dgvDetails
                  > .Visible = True
                  > .AllowUserToAdd Rows = False
                  > .AllowUserToDel eteRows = False
                  > DetailsBindingS ource = New
                  > BindingSource(P ortDetailsDataS et, dt.TableName)
                  > .DataSource = DetailsBindingS ource
                  > tabDetails.Cont rols.Add(dgvDet ails)
                  > dgvDetails.Dock = DockStyle.Fill
                  > dgvDetails.Scro llBars =
                  > System.Windows. Forms.ScrollBar s.Both
                  > For Each a As DataGridViewCol umn In .Columns
                  > a.ReadOnly = True
                  > Next
                  > .ScrollBars = System.Windows. Forms.ScrollBar s.Both
                  > End With
                  > Next
                  > End If
                  >
                  > BTW, on a side note I allow the user to clear the tabs from the
                  > tabcontrol assuming that because the dynamic bindingsources and
                  > datatables are no longer referenced the VS garbage collecter will clean
                  > them up. Is that a correct assumption or should I delete the referenced
                  > objects myself?
                  >
                  > Thanks,
                  >
                  > Crazy
                  > Crazy Cat wrote:[color=green]
                  >> I don't have a binding source because I don't use the DataSet designer
                  >> to get the tables back. Perhaps that'll help? I'll take a look and post
                  >> back.
                  >>
                  >> Thanks,
                  >>
                  >>
                  >> Cor Ligthert [MVP] wrote:[color=darkred]
                  >> > Crazy,
                  >> >
                  >> > With this code I see a vertical and a horizontal scrollbar
                  >> >
                  >> > \\\
                  >> > Dim mydatagridview As New DataGridView
                  >> > Controls.Add(my datagridview)
                  >> > mydatagridview. DataSource = MyEmployeesBind ingSource
                  >> > ///
                  >> >
                  >> > I hope this helps,
                  >> >
                  >> > Cor[/color][/color]
                  >[/color]


                  Comment

                  • Crazy Cat

                    #10
                    Re: Dynamic DataGridView missing horizontal scrollbar


                    Cor Ligthert [MVP] wrote:[color=blue]
                    > Crazy Cat,
                    >
                    > Because that I see "Dock Fill" are you sure that your DataGridView is narrow
                    > enough to show the horizontal scrollbar?
                    >[/color]

                    It should be, even when the application is maximized I can only see
                    about 50 - 60 % of the columns.

                    Thanks,
                    [color=blue]
                    > Cor
                    >
                    > "Crazy Cat" <danbredy@hotma il.com> schreef in bericht
                    > news:1144265673 .701410.259600@ u72g2000cwu.goo glegroups.com.. .[color=green]
                    > > OK,
                    > >
                    > > I tried this again with the Binding Source and still no scrollbar --
                    > > does anyone have any other ideas???? PLEASE???
                    > >
                    > > Here's the code --
                    > >
                    > >
                    > > Dim tabDetails As TabPage
                    > > Dim DetailsBindingS ource As BindingSource
                    > > Dim dgvDetails As DataGridView
                    > >
                    > > tctlDetails.Tab Pages.Clear()
                    > > If PortDetailsData Set IsNot Nothing Then
                    > > For Each dt As System.Data.Dat aTable In
                    > > PortDetailsData Set.Tables
                    > >
                    > > Me.tctlDetails. TabPages.Add(dt .Rows(0).Item(" MSC_NAME"))
                    > > tabDetails =
                    > > tctlDetails.Tab Pages(tctlDetai ls.TabPages.Cou nt - 1)
                    > > dgvDetails = New DataGridView()
                    > > With dgvDetails
                    > > .Visible = True
                    > > .AllowUserToAdd Rows = False
                    > > .AllowUserToDel eteRows = False
                    > > DetailsBindingS ource = New
                    > > BindingSource(P ortDetailsDataS et, dt.TableName)
                    > > .DataSource = DetailsBindingS ource
                    > > tabDetails.Cont rols.Add(dgvDet ails)
                    > > dgvDetails.Dock = DockStyle.Fill
                    > > dgvDetails.Scro llBars =
                    > > System.Windows. Forms.ScrollBar s.Both
                    > > For Each a As DataGridViewCol umn In .Columns
                    > > a.ReadOnly = True
                    > > Next
                    > > .ScrollBars = System.Windows. Forms.ScrollBar s.Both
                    > > End With
                    > > Next
                    > > End If
                    > >
                    > > BTW, on a side note I allow the user to clear the tabs from the
                    > > tabcontrol assuming that because the dynamic bindingsources and
                    > > datatables are no longer referenced the VS garbage collecter will clean
                    > > them up. Is that a correct assumption or should I delete the referenced
                    > > objects myself?
                    > >
                    > > Thanks,
                    > >
                    > > Crazy
                    > > Crazy Cat wrote:[color=darkred]
                    > >> I don't have a binding source because I don't use the DataSet designer
                    > >> to get the tables back. Perhaps that'll help? I'll take a look and post
                    > >> back.
                    > >>
                    > >> Thanks,
                    > >>
                    > >>
                    > >> Cor Ligthert [MVP] wrote:
                    > >> > Crazy,
                    > >> >
                    > >> > With this code I see a vertical and a horizontal scrollbar
                    > >> >
                    > >> > \\\
                    > >> > Dim mydatagridview As New DataGridView
                    > >> > Controls.Add(my datagridview)
                    > >> > mydatagridview. DataSource = MyEmployeesBind ingSource
                    > >> > ///
                    > >> >
                    > >> > I hope this helps,
                    > >> >
                    > >> > Cor[/color]
                    > >[/color][/color]

                    Comment

                    • wakeup

                      #11
                      Re: Dynamic DataGridView missing horizontal scrollbar

                      did you solve it? I have the same problem
                      thankss!





                      ---
                      Posted via DotNetSlackers. com

                      Comment

                      Working...