I am using NetAdvantage for .NET 2008 Vol. 2 CLR 2.0.
I have several questions regarding adding a button to a UltraWinGrid column header and having it do something useful.
Right now, I have managed to create the buttons by using a CreationFilter on the UltraWinGrid; i.e. I set
in the form's Load event.
The function itself is pretty basic:
btnElement.Rect = New Rectangle(parent.Rect.X + 2, parent.Rect.Y, _
End If
End Function
The buttons show up on every column header, but now the captions don't appear! So I have four questions:
here is what i did to get this to work for my grid (although not 2008 version)...sorry the format sucks, the textarea for their website needs to be better, but i try to format as best as i could.
Private
Infragistics.Win.UIElementEventArgs) _
ugDetail.MouseEnterElement
(Infragistics.Win.UltraWinGrid.UltraGridCell)), UltraGridCell)
Then
ToolTip1.SetToolTip(
)
Else
If
(sender, Windows.Forms.Control), acell.Text)
Sub
Hi David, would you mind posting some code that you eventually implemented for getting the button and label?
Also being very new to CreationFilter I am not sure how your class AddUpdateButtonsCreationFilter() relatesto the function BeforeCreateChildElements
Lastly how did you resolve the tooltip question.
Thanks!
Hi David,
1. Your code here adds a child element to the HeaderUIElement and then you are returning True from BeforeCreateChildElements. Returning true tells the control not to add the default elements, which includes the TextUIElement which shows the text of the caption. So you don't want to do that. What you probably need to do is handle AfterCreateChildElement instead of Before. Then you can re-position the existing text element to make room and add your button. Note that the AutoSizing of the column is not going to take your button into account. So you may need to set a MinWidth on the column to prevent the header text getting clipped.
2. You can't set properties on the element, because the element itself will get destroyed and recreated quite often. So you will need to store the visibility of the button yourself in a variable somewhere, then just have the CreationFilter check the property and don't create the button if it's not visible. Maybe you could use the Tag property on the column header.
3. I think you have to derive a class from ButtinUIElement and override the OnClick method - instead of using a ButtonUIElement directly.
4. You would have to do this the same way you would add a tooltip to any part of a control. Use the MouseMove event and use the ElementFromPoint method to determine what part of the grid the mouse is over and then set the tooltip on the control.