PictureBox and HScrollBar
I want to add an horizontal scroll bar to my picture box. I am relatively new to C# so this may seem like a dumb question, but, how do I add a horizontal scroll bar to my picture box class and catch the scroll events in my picture box class.
I added both a picture box and hscrollbar control to my form. In the OnLoad event in my form, I set the handle to the scroll bar in the picture box. I am not sure this is the right way to do this because I don't know how to catch the scrolling event in my picture box?
public class BedPlanView : PictureBox
{
private IntPtr _hScroll;
public IntPtr HScroll
{
get { return _hScroll; }
set { _hScroll = value; }
}
}
public class MainForm
{
private void _main_Load(object sender, EventArgs e)
{
this.CenterToScreen();
_bedPlan.HScroll = _hScroll.Handle;
}
}
Any suggestions?
Mike B
Mike B
[1028 byte] By [
MikeB] at [2007-11-20 9:42:42]

# 1 Re: PictureBox and HScrollBar
Ok, so after a little investigation, it seems it may be better to create a custom control using the windows control library. My problem now is that I have a common class that two custom controls use. I dont' want to create this class in both projects. How do I create a class that can be used in both controls?
I know the above is not that clear so I will try to clarify. I have a data class called PlotFile. I need a picture control class that displays a single PlotFile object and a picture control that displays a collection of PlotFile objects. How can I create a PlotFile class that can be used in both picture controls without having to write the PlotFile class in both custom controls?
Mike B
MikeB at 2007-11-9 11:34:39 >

# 2 Re: PictureBox and HScrollBar
OK, so I am answering my own questions, sue me? :)
I found the option to create a windows library project, so to do this, I would create a PlotFile.dll.
I am going to experiment with this, but I am not sure this is the right decision for my project. Is it better to break down the custom classes and custom controls into dll files or just create it all in one project?
Mike B
MikeB at 2007-11-9 11:35:40 >
