Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]
Posted

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.

  • Leaders
Posted

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).

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...