Hello all..
I'm currently working with an UltraGrid control with a bound data source to a generic list. What I'm hoping to accomplish is to embed a custom user control in the child band for each of the items displayed in the grid. I have done some searching on the forums, and found some posts that refer to a method of utilizing the UltraExplorerBar, UltraControlContainerEditor, and the UltraControlContainerEditor, but the example given was done solely through the designer. This is not an optional approach for me, and I need to achieve the same results programmatically.
Based on the designer code inside the example, this is what I've come up with so far..
Private _userContainer As New Infragistics.Win.UltraWinEditors.UltraControlContainerEditor Private _ebContainerCtl As New UltraExplorerBarContainerControl Private _projSumCtl As New MyUserControl() Private _headerAppearance As New Infragistics.Win.Appearance With {.BackColor = Color.WhiteSmoke, .BackColor2 = Color.Silver, .BackGradientStyle = GradientStyle.GlassTop37}
Private Sub SetupEmbeddedDetailsControl() _ebContainerCtl.Controls.Add(_projSumCtl) _userContainer.RenderingControl = explorerBar
explorerBar.Controls.Add(_ebContainerCtl)
With explorerBar Dim group As New UltraExplorerBarGroup("ProjectDetails") .Groups.Add(group) group.Container = _ebContainerCtl group.Text = "Project Details" .Size = _projSumCtl.Size
.TabIndex = 1 .Visible = False
.GroupSettings.AppearancesSmall.HeaderAppearance = _headerAppearance .GroupSettings.AppearancesSmall.ActiveAppearance.BackColor = Color.WhiteSmoke .GroupSettings.HeaderButtonStyle = UIElementButtonStyle.ButtonSoft .GroupSettings.Style = GroupStyle.ControlContainer .Style = UltraExplorerBarStyle.VisualStudio2005Toolbox End With
With Me.DisplayLayout.Bands(1) .Columns.Add("Details") .Columns("Details").EditorComponent = _userContainer End With End Sub
If possible, can someone tell me if this is headed in the right direction or provide some example for achieving this programmatically? I'm not using an UltraDataSource like the example does, but that's the only major difference I've been able to notice.
I'm currently using v11.2 controls.
Thanks!
Hi,
I'm a little unclear on exactly what you are trying to do, but I think your code here might be on the wrong track.
The UltraControlContainerEditor allows you to embed a control (any control) into a cell in the grid. But the control in question needs to be designed in such a way that it deals with a single value that it gets from the grid cell. So I'm not very clear on where the ExplorerBar control comes into play here. You seem to be just using an ExplorerBar, so then why do you need a UserControl?
Is that what you want - an ExplorerBar in a grid cell? If so, then how does the ExplorerBar link up to the cell's value? What is the data type of the column you are using here and how do those values relate to the ExplorerBar?
There are samples included with NetAdvantage (assuming you chose to install them) which demonstrate how to set up the UltraControlContainerEditor at run-time. So you should probably take a look at those first. The location on the hard drive is something like this:
...\2011.2\Samples\WinEditors\VB\ControlContainerEditor VB
I'll try to clarify a little more on what I'm trying to achieve...
I have a custom user control, that allows the user to view detailed summary information for the bound object whenever the parent row for that object is expanded. For example, if I have a "Project Item" as the parent row list object, and I click the expansion indicator to the left of the row, I want the child band to contain my custom user control and be populated for that project's detailed summary.
Based on your reply, I'd need to have my project item to contain a "Details" property that would create my child band within the grid. Then use the "Details" for that "Project Item" to apply the renderer class to the user control, which should populate my user control for that row with the information provided. Correct, or am I misunderstanding the process here?
I've been looking at the local ControlContainerEditor example, and have tried to create my own "renderer" class to assign to the .Editor property for the specified column. This does render the control like it's supposed to, but the user control isn't being populated with the row's information. Does this assignment have to occur within the InitializeLayout event, since it's on a per-row basis? If so, how can I achieve the proper information for each child rows' information inside of that event?
Thanks for the quick reply and detailed assistance!
I guess my real question here is:
How do I populate each individual control with the appropriate underlying data?
The example in the locally installed samples utilizes a UltraGauge, which has previously defined values that can be set in the "Me.Marker" property. I'm using a custom control with a variety of WinForms controls, like labels, textboxes, and images.
I'm confused as to where the underlying data needs to be set, whether on the custom control or through the renderer class, so that it can be populated for each row automatically. If I understand it correctly, the renderer just tells the grid that for the specified column, the data should be displayed via the user control.
I can't seem to bridge that gap by looking at the example.
The EditingControl and/or RenderingControl in the cell get their information from the Value of the cell.
You can use RenderingControlProperty and EditingControlProperty to determine which property on your custom control gets/set the cells Value. But everything has to go through that one property.
If you are using a TextBox as your RenderingControl, for example, the TextBox's Text property will be set by the grid cell and vice versa.
For more complex controls, your cell value might need to be a more complex data type, but you need a single property which can get get/set on your control.
Mike -
I would like to see an example of using a TextBox as the rendering control.
When I try to use one as the rendering control, it does not show up. The TextBox will only show up when using it as the editing control, and only after I click on the row.
Thank you
That's kind've an odd request. If you don't specify a RenderingControl at all, the ControlContainerEditor will display raw text for you automatically. So why wyould you want to use a TextBox as a RenderingControl? Unless you've set some properties on the TextBox that make it display something unusual, there wouldn't be much point.
I can't think of any reason why the control would not display, though. TextBox is one of the simplest controls you could use. Can you post a sample project where you are using a TextBox as the RenderingContorl and it's not displaying?
I could create a sample for you, but really, it wouldn't be any different than any of the existing samples that are including with the product.