none
WPF Gridview Column Showing

    Question

  • Hi,

      I am using the wpf gridview and values are loaded from the database, I have loaded 50 columns in my gridview.

     So my requirtment is just i want to display 10 column while page is loading , in that gridview down i have two button next and previous, so if i have click the next button means another 10 columns i need to display again 10 columns like that i have to display.suppose if i click the previous button means previous 10 column are going to display.

    how to display..please help me.

    Tuesday, August 16, 2011 12:12 PM

Answers

  • Hi Soundar,

    I suggest to use a ScrollViewer to accomplish this.

    Here is a simple sample.

      <StackPanel>
        <ScrollViewer Name="MyScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Width="400" Height="200">
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="Col1-10" Width="400"/>
            <TextBlock Text="Col11-20" Width="400"/>
            <TextBlock Text="Col21-30" Width="400"/>
            <TextBlock Text="Col31-40" Width="400"/>
            <TextBlock Text="Col41-50" Width="400"/>
          </StackPanel>
        </ScrollViewer>
        <Button Command="ScrollBar.PageLeftCommand" CommandTarget="{Binding ElementName=MyScrollViewer}" Content="Previous"/>
        <Button Command="ScrollBar.PageRightCommand" CommandTarget="{Binding ElementName=MyScrollViewer}" Content="Next"/>
      </StackPanel>
    

    Hope this helps.


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 23, 2011 7:26 AM
    Moderator

All replies

  • Hi,

    You can create runtime gridview, everytime it creates a bunch of columns.

    Thanks,

    Rajnikant

    Tuesday, August 16, 2011 12:42 PM
  • Hi,

       I am already created the runtime gridview, my task is Once all the colums are loaded i have to show 10 columns so next button click i have to show another 10 columns. as well as previous button click.

      First time only i fetching the values from database after that i am processing the front end itself.

    how to populate this. Plz help me.

    thanks,

    Wednesday, August 17, 2011 12:14 PM
  • Hi Soundar,

    I suggest to use a ScrollViewer to accomplish this.

    Here is a simple sample.

      <StackPanel>
        <ScrollViewer Name="MyScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Width="400" Height="200">
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="Col1-10" Width="400"/>
            <TextBlock Text="Col11-20" Width="400"/>
            <TextBlock Text="Col21-30" Width="400"/>
            <TextBlock Text="Col31-40" Width="400"/>
            <TextBlock Text="Col41-50" Width="400"/>
          </StackPanel>
        </ScrollViewer>
        <Button Command="ScrollBar.PageLeftCommand" CommandTarget="{Binding ElementName=MyScrollViewer}" Content="Previous"/>
        <Button Command="ScrollBar.PageRightCommand" CommandTarget="{Binding ElementName=MyScrollViewer}" Content="Next"/>
      </StackPanel>
    

    Hope this helps.


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 23, 2011 7:26 AM
    Moderator