tailieunhanh - Manning Windows Forms Programming (phần 6)
Tham khảo tài liệu 'manning windows forms programming (phần 6)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Our focus in this section will be the Panel class. This class can contain and position controls just like the Form class and supports automated scrolling since it inherits from the ScrollableControl We will not position controls within a panel in this chapter but we will use this class to fix some of the problems we have seen when drawing directly on the form. We will draw our photo directly in a Panel and solve the following problems we noticed when drawing directly on the form Our image was off-center vertically for the Scale to Fit display option. The DisplayRectangle property included the vertical space occupied by the scroll bar which threw our calculations off. Here we will use the panel s DisplayRectangle property so that the image will be centered exactly inside the panel. The 3-D border we used for the PictureBox control was gone. We could have attempted to draw a border inside the form using the method but a Panel provides a much easier solution. The Panel class provides a BorderStyle property much like the corresponding PictureBox property so the .NET framework will draw the border for us. The status bar was part of the scrollable area. Since the Form object managed the scrolling the StatusBar control on the form was caught up in the scrolling logic. In this section the scrolling will be managed by the Panel class independent of the form and status bar. As a result our status bar will return to and remain at its natural position at the base of the form. Before we get into the required changes figure shows how our three display modes will appear by the end of this section. As you can see the application looks much more polished here than when we drew directly on the form. Note especially the excellent centering the fine border and the well-behaved scroll bars. Figure This shows an image drawn inside a panel with the Scale to Fit Stretch to Fit and Actual Size display modes. 2 For the curious the GroupBox control
đang nạp các trang xem trước