Results 1 to 5 of 5

Thread: how to auto scroll hscrollbar in C#

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    90

    how to auto scroll hscrollbar in C#

    Hi Sir,

    how to auto scroll my horizontal scroll bar when i click ok in message box ?
    this is the concept of my simple game.

    this is my level 1 interface, if the user get the correct answer ,dialog will appear "Correct"

    Name:  1.PNG
Views: 780
Size:  9.8 KB

    when user click Ok , I want to move the Hscrollbar to show the next level.

    Name:  1.1.PNG
Views: 781
Size:  25.2 KB


    show level 2 as below. how can i code that ?
    Name:  2.PNG
Views: 753
Size:  9.9 KB


    if correct it will show messagebox and after click ok i want the scroll bar to move to 341 value to show the next LEVEL but it is not moving. please help me.
    Code:
      private void btnGuess_Click(object sender, EventArgs e)
            {
                if (lblRemember.Text == txtAnswer.Text)
                {
                
                    MessageBox.Show("Correct");
                     newhscrollbar.Value = 341;
                    newhscrollbar.Maximum = 345;
                    newhscrollbar.Minimum = 0;
                   //Other condition
                    txtAnswer.Clear();
                    txtAnswer.Focus();
                    Generator();
                    lblRemember.Show();
                    lblLevel.Text = (int.Parse(lblLevel.Text) + 1).ToString();//increase level
                    Generator();
                    txtAnswer.Enabled = false;
                   
    
                }

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to auto scroll hscrollbar in C#

    Why are you asking hot to do something in C# in a VB.NET forum? This site has a C# forum so use that. I've asked the mods to move this thread.

    For the record, I would have had a go at answering if it had been posted in the right place but I'm not going to look at the question until it's been moved.

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: how to auto scroll hscrollbar in C#

    Thread moved from the 'VB.Net' forum to the 'C#' forum

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    90

    Re: how to auto scroll hscrollbar in C#

    hi sir,

    Sorry sir , Im new to this forum didn't notice that C# can be separated. please help me in my coding thank you.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: how to auto scroll hscrollbar in C#

    I don't really understand why you're asking this question at all because the code you posted indicates that you already know how to set the position of the scroll bar handle. What is the actual issue? Also, have you read the documentation for the HScrollBar control? If you are using a new type then you should ALWAYS cast your eye over the documentation for that type to see what members it has and if there are any specific points of interest.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width