bufer24 Posted July 24, 2012 Posted July 24, 2012 Is there a way to extend the bounds of a control, so that it has some extra space between the physical boundary and the graphical edge? Look at the image in attachment that demonstrates what I want to achieve. In this case it is a datagridview with some extra space on the right. Sure, I could put it inside a usercontrol, but I want this control to Inherit directly from DataGridView. Quote
Leaders snarfblam Posted July 24, 2012 Leaders Posted July 24, 2012 Maybe you should explain what the end goal is here. If you inherit a control, the base class still decides how it wants to use the space within the control (in most cases, it will consume it's entire rectangle), so you do can't things the way you would like. There is probably another way to achieve whatever you're trying to do. Quote [sIGPIC]e[/sIGPIC]
bufer24 Posted July 26, 2012 Author Posted July 26, 2012 The goal is to use the empty space for some other controls. I could add for example a button to the grid like this: MyGrid.Controls.Add(MyButton). The reason I am looking for this kind of solution is that I don´t want to put the datagrid into a usercontrol and then expose the column collection using some extensive code (i.e. writing my own columncollection editor and who knows what else). I still want the control to behave mainly as datagridview. Quote
Leaders snarfblam Posted July 26, 2012 Leaders Posted July 26, 2012 I understand where you're coming from, but the approach you're after just isn't possible. A composite control (user control holding everything) would be the typical approach. If that's going to cause problems like mucking up the designer, there's another solution that comes to mind. You can create a separate companion control that inherits UserControl and contains the additional controls. Inherit DataGrid and extend it to either: (1)Cooperate with the companion control. The extended DataGrid is responsible for adding/removing/managing controls within the companion. Or, (2) Expose properties that the companion can examine and manage the child controls itself. The programmer would be responsible for placing an ExtendedDataGrid and a DataGridCompanion, and wiring them together (i.e. setting dataGridCompanion1.OwnerGrid = extendedDataGrid1). Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.