Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two HcrollBars ow which one is attached to Form1. I can move the hScrollBar1 to the midway position (50) without any problem. The other HorizontalScrollBar is attached to the bottom of richTextBox1, but I could not move it programatically.

Please help me.

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            pp();
        }

        private void pp()
        {
            hScrollBar1.Value = 50;//<--- No Error

            // Property WordWrap is False for the next HScroll
            this.richTextBox1.HScrollBar.Value = 50;// <--- Error
            richTextBox1.HScroll.Value = 50;//<- Error Value not 
      //member 
        }

    }
}
Posted
Updated 6-Feb-11 6:53am
v2

1 solution

I'm puzzled: there is not such property: System.Windows.Forms.RichTextBox.HScrollBar!!
You probably mixed up something. You could would not compile even if you don't assign it a value.

—SA
UPDATE:
[SM]: Just adding a link to all available properties for RichTextBox class: MSDN: RichTextBox Class[^]

Sandeep, do you confirm that there is no such property, in case I've gone crasy? :-)
There is not such property, correct?

—SA
 
Share this answer
 
v3
Comments
TweakBird 6-Feb-11 13:57pm    
No such property. It having only ScrollBars as Property and it's enum(RichTextBoxScrollBars) values are "None,Horizontal,Vertical,Both,ForcedHorizontal,ForcedVertical,ForcedBoth"
TweakBird 6-Feb-11 13:59pm    
Addition to SA, Have a look on these also 1) http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.scrollbars(v=VS.90).aspx 2) http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextboxscrollbars.aspx
Sergey Alexandrovich Kryukov 6-Feb-11 17:42pm    
Thank you. The question might be not trivial. I think the purpose is to bring some part of the text into view (unfortunately OPs often do not share the ultimate goals, hence got unusable answers).
I would avoid solving such problem and put forward alternative design instead.
Such question are often result from design mistakes.
--SA
Espen Harlinn 6-Feb-11 14:25pm    
My 5, None that's documented - but you do have as E$w@r mentioned RichTextBox.ScrollBars. So conceivably they might be there as child windows, but they are not – Spy++ shows that the scrollbars for the rich text control does not have its own handle.
Sergey Alexandrovich Kryukov 6-Feb-11 14:34pm    
Thank you, Espen,
I wanted to answer formally, the OP should not be treated as a kindergarten child; this is my way to show some respect...
You could post your own answer based on what you say.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900