I have richTextBox (dock style = fill, scrollbar = only vertical, wordwrap = false) in splitcontainer.panel1
splitcontainer.panel1.Controls.Add(richTextBox);
In case when richTextBox needs to be scrolled (when its width is bigger than width of splitcontainer.panel1).
I wish a scrollbar would appear (but in splitcontainer.panel1, not scroll bar from richTextBox).
Is it possible to handle?
It certainly doesn't make sense to do that. For the sub-panel's scrollbars to even work properly, you couldn't dock-fill the RichTextBox control. Then you would have to constantly resize the RichTextBox control based on the TextChanged event, and that could get messy.
It's also not clear why you couldn't just set the ScrollBars to both:
richTextBox.ScrollBars = RichTextBoxScrollBars.Both;
It would seem to do the job you really want it to do.
Related
I have an application written for a touchscreen. It mainly consists of a listview and a DataGridview. the default control scrollbars are too narrow for gloved hands, so i would like to increase the width of the scroll bars in those two controls.
I don't see any way to do it in the designer, so I started working with the VScrollBar control; however, this does not replace the default scrollbar for those controls, rendering it ineffective.
So, my question is twofold:
Can I override the width of the default scrollbar?
If not, can I somehow make the new VScrollbar the default for that control?
I have a question about WinForm TableLayoutPanel control. For example, if I hide the control in the column. it will change the size.
Is there a way to not paint the control in a tablelayoutpanel with column autosize so that the column will still have the control size?
Using Control.Visible = false will make the column width 0.
I need something like hidden in WPF Grid.
You can place a Panel in the TLP and place the control on the panel. Set the panel's background color to the same as the TLP, and it will be invisible. Then hide the control but leave the panel.
This should work fine if your control is a fixed size. If the control size varies, it might be a bit more tricky to do this. You will need to vary the size of the Panel too. Setting it to AutoSize = true and AutoSizeMode = GrowOnly might work.
I have a windows form with two controls, one mail control (Dock = Fill) and a property control (Dock = Right). The property control is set to AutoScroll. It has some expandable panels and if the user expands too many panels the height of the control is larger than the window height and I set the AutoScroll property in order to automatically display scrollbars in this case - this does work. However the scrollbar is plotted over the property controls. The scrollbars of course needs some place but I would like the property window to grow in width as long as the scroll bar is shown (and hence reduce the size of the main control a bit) so that the scrollbar is on the right side of the property control which is completely shown.
Can you give me a hint? Do I need to change some properties of the controls? Or is there an Event "ScrollBarsShown" or something which I could catch and manually extend the width of the property control?
Thank you very much!
Put these controls in a TableLayoutPanel. The arrangement should be two columns, one row. Column0 would be set to 100%, while Column1 would be AutoSize. The Row could be either.
Then just dock fill the TableLayoutPanel in your form.
Is there a way to make the label text move as in marquee but in windows form application , thanks.
Thanks.
It isn't exactly clear where you might want to move the text to, if it doesn't fit the layout then there are no real options. In general, window layouts are contrained width-wise but have some room for growth vertically. Enforce this by setting the Label's MaximumSize property to, say, (100,0) so it cannot grow in the width and overlap some other control. That will make it start wrapping text and use more vertical space.
If that's a problem as well then set AutoSize = False and AutoEllipsis = True. The user can now tell that the text got truncated. And automatically gets a tooltip when she hovers the label.
I'm using a ScrollViewer to display an Image. The Image has a ScaleTransform set as one of it's LayoutTransforms. I've got it setup to fit the width of the image into the ActualSize of the ScrollViewer. My problem is that if the image height requires the vertical scrollbar to be present (I have it set to Auto) then my image is scaled just a little bit to much. I know how to determine if the scrollbar would be present and how to get the correct scale, but I cannot figure out how to determine what the actual width of the scrollbar is. I guess I could just guess at it, but I'd like something that would work if I later add styles to my application that would result in the scrollbars being a different size. Additionally I'm also doing Fit to Height and would need to get the Height of the horizontal scrollbar when it would be visible (I'm assuming that the answer to getting the width of the vertical scrollbar would make getting the height of the horizontal scrollbar obvious).
You can use SystemParameters.ScrollWidth.
Using ViewableHeight and ViewableWidth instead of ActualHeight and ActualWidth in my scaling calculations along with setting the scroll bars Visibility to Visible instead of Auto works. However I'll accept another answer that allows the scroll bars to be set to Auto instead.
Edit:
OK, I've now got the scroll bars set to Visible. Then I do my calculation with the ViewableHeight and ViewableWidth. Then I set the scroll bars back to Auto. This seems to work even if it's not all that elegant.