Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Horizontal Scrollbar to a PropertyGrid
 

Horizontal Scrollbar to a PropertyGrid

All,

I am working on C# and.NET. Iam facing difficulty in setting up a horizontal scrollbar to a propertygrid. I have a propertygrid and assigned it to a class (Student.cs). This property grid is having a dropdown list where lenght of the input values may exceeds 25 characters such a way that user can not see full string in the propertygrid. In order to see full string, I am trying to set up a horizontal scroll bar to it. But, I failedin setting up. Can we give a horizontal scrollbar to a propertygrid. Please, help me in the same. Thanks in advance.

I hope, this is the right place to ask this question. Let me know if further information is needed.

Kumar...  Tuesday, February 17, 2009 6:16 AM

Hi Kumar,

Thank you for your prompt reply!

I'm afraid it's impossible to set up a horizontal scollbar to a PropertyGrid because we have no way to scroll the content in the PropertyGrid horizontally with code.

If you have anything unclear, please feel free to let me know.

Sincerey,
Linda Liu

  • Marked As Answer byKumar... Friday, February 20, 2009 1:01 PM
  •  
Linda Liu  Thursday, February 19, 2009 4:13 AM

Hi Kumar,

The VerticalScroll and HorizontalScroll property of the PropertyGrid are inherited fromitsbase class ScrollableControl. If you also set the PropertyGrid.VerticalScroll.Visible property to true in the InitializeComponent method or in the form's constructor, you will see a vertical scrollbar appears near the right border of the PropertyGrid, but it is not the same vertical scrollbar that the PropertyGrid actually uses.

In fact, PropertyGrid doesn't use the VerticalScrollbar or HorizontalScrollbar inherited from the ScrollableControl class. Instead, it implements its own vertical scrollbar.This vertical scrollbarwillappear inthe content areawhen theproperty items shownin the PropertyGrid exceeds the visible view in the PropertyGrid.

Hope I make some clarifications.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

  • Marked As Answer byKumar... Friday, February 20, 2009 1:01 PM
  •  
Linda Liu  Friday, February 20, 2009 3:04 AM

Hi Kumar,

Firstly, the ProperyGrid only provides a vertical scrollbar. When the property items shown in the PropertyGrid exceeds the visible view in the PropertyGrid, the vertical scrollbar will be shown automatically.

> This property grid is having a dropdown list where lenght of the input values may exceeds 25 characters such a way that user can not see full string in the propertygrid.

By "dropdown list", do you mean the dropdown list for a property item in the PropertyGrid? If so, I don't think it is appropriate to set up a horizontal scrollbar to show the fullvalue of the property item.

Sincerely,
Linda Liu

Linda Liu  Wednesday, February 18, 2009 8:28 AM
Hi Linda Liu


Thank you very much for your reply. You areabsolutely correct. The dropdown list which i have mentioned is nothing but a dropdownlist for a property item(e.g., Name of the Student: ) in the property grid.


But, in general, is it possible to set up a horizontal scrollbar to a propertygrid? If it is possible, please share with me. Thank you.

Kumar...  Wednesday, February 18, 2009 11:10 AM

Hi Kumar,

Thank you for your prompt reply!

I'm afraid it's impossible to set up a horizontal scollbar to a PropertyGrid because we have no way to scroll the content in the PropertyGrid horizontally with code.

If you have anything unclear, please feel free to let me know.

Sincerey,
Linda Liu

  • Marked As Answer byKumar... Friday, February 20, 2009 1:01 PM
  •  
Linda Liu  Thursday, February 19, 2009 4:13 AM
Hi Linda Liu,

Thank you for your reply.

But, while solving the problem, what i have observed is propertygrid control is having a provision to use HorizontalScrollbar property to enable the scrollbar. I have tried by usingHorizontalScrollbar property (code snippet is given for your reference).

1 //
2 //propertyGrid1
3 //
4 this.propertyGrid1.Dock=System.Windows.Forms.DockStyle.Fill;
5 this.propertyGrid1.Name="propertyGrid1";
6 this.propertyGrid1.Size=newSystem.Drawing.Size(292,273);
7 this.propertyGrid1.HorizontalScroll.Enabled=true;
8 this.propertyGrid1.HorizontalScroll.Visible=true;
9 this.propertyGrid1.HorizontalScroll.Minimum=0;
10 this.propertyGrid1.HorizontalScroll.Maximum=100;
11

By including the (last 4 lines) inInitializeComponent(), I am able to see the horizontal scrollbar on properttygrid. But,after moving scrollbarto some extent,scrollbarwill regain its initial position automatically on releasing the left click. Content in the propertygrid isremains same in position even if you disturb the scrollbar.

I do not know why it is happening like that. Can you please explain the exact purpose of having HorizontalScrollbar property to the propertygrid control. Suggest me if I am wrong in implementing the code for my need.

Regards,
Kumar.
Kumar...  Thursday, February 19, 2009 5:43 AM

Hi Kumar,

The VerticalScroll and HorizontalScroll property of the PropertyGrid are inherited fromitsbase class ScrollableControl. If you also set the PropertyGrid.VerticalScroll.Visible property to true in the InitializeComponent method or in the form's constructor, you will see a vertical scrollbar appears near the right border of the PropertyGrid, but it is not the same vertical scrollbar that the PropertyGrid actually uses.

In fact, PropertyGrid doesn't use the VerticalScrollbar or HorizontalScrollbar inherited from the ScrollableControl class. Instead, it implements its own vertical scrollbar.This vertical scrollbarwillappear inthe content areawhen theproperty items shownin the PropertyGrid exceeds the visible view in the PropertyGrid.

Hope I make some clarifications.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

  • Marked As Answer byKumar... Friday, February 20, 2009 1:01 PM
  •  
Linda Liu  Friday, February 20, 2009 3:04 AM

Hi Linda Liu,

Thank you very much for your reply. Your suggestions helped me a lot........Thank you.

Regards,
Kumar

Kumar...  Tuesday, March 03, 2009 11:26 AM

You can use google to search for other answers

Custom Search

More Threads

• usercontrol !
• User Control (text box), Null values, Formatting
• Docking Window Management Control
• virtual scroll ring
• Converting Forms to TabPages
• DatetimePicker in datagridview
• Gradient datagridview columnheader
• Show control (not inherited from UserControl) in design time
• Custom ControlDesigner for a user control hosted in Internet Explorer
• Unable to move the position of custom control during design time