This is a migrated thread and some comments may be shown as answers.

How to hide the shadow in a RadCalculatorDropDown

3 Answers 167 Views
CalculatorDropDown
This is a migrated thread and some comments may be shown as answers.
Jorge
Top achievements
Rank 1
Jorge asked on 07 Feb 2015, 09:54 PM
I'm trying to add a calculator to my project. I'm thinking that if I use a Rad Calculator DropDown with the popup opened inside an empty form it might work.

So far I have the form as you can see in the attached picture. I did hide the popup border using:

        Me.RadCalculatorDropDown1.CalculatorElement.CalculatorContentElement.DrawBorder = False


I did also hide the arrow button but I can't figure out how to hide the shadow.
My other problem is that when I click the textbox the popup calculator it goes away

It would be nice that you provide a full calculator control. 

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 10 Feb 2015, 01:43 PM
Hello Jorge,

Thank you for contacting us.

I have attached a sample project which creates calculator with implementation based on RadCalculatorDropDownFeel free to refer to it or edit it and do not hesitate to write again if you have any additional questions.

I have logged this in our feedback portal as a feature request. You can find the feedback item here: http://feedback.telerik.com/Project/154/Feedback/Details/150604-add-radcalculator-a-new-control-which-allows-placing-the-calculator-on-a-form

Your Telerik points have been updated for this request.

If you want to keep your current approach you can use the following solutions:
To hide RadCalculatorDropDown popup shadow you can subscribe to the CalculatorElement's PopupOpening event and set the DropShadow property to false.
void CalculatorElement_PopupOpening(object sender, CancelEventArgs e)
{
    radCalculatorDropDown1.CalculatorElement.Popup.DropShadow = false;
}

To prevent the popup from closing you can subscribe to the CalculatorElement PopupClosing event and cancel it.
void CalculatorElement_PopupClosing(object sender, RadPopupClosingEventArgs args)
{
    args.Cancel = true;
}

I hope this helps.

Regards,
Todor Vyagov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jorge
Top achievements
Rank 1
answered on 10 Feb 2015, 08:11 PM
Awesome. I did convert your code to VB and now is working fine as you can see in my attachment. However I'm still having a little problem, The following keys: + - * / are not responding from the keyboard, the work fine only after you click their buttons. Any thoughts?


Imports Telerik.WinControls
Imports Telerik.WinControls.UI
 
Public Class Calculator
 
 
    Dim calculator As New CustomCalculator()
    Dim calculatorContentElement As RadCalculatorContentElement = TryCast(calculator.RootElement.Children(0).Children(1), RadCalculatorContentElement)
 
    Public Sub New()
 
        InitializeComponent()
 
        calculator.Size = New Size(270, 300)
        calculatorContentElement.DrawBorder = False
        Me.Controls.Add(calculator)
 
    End Sub
 
 
    Public Class CustomCalculator
        Inherits RadControl
        Protected Overrides Sub CreateChildItems(parent As RadElement)
            MyBase.CreateChildItems(parent)
            Dim element As New CustomCalculatorElement()
            parent.Children.Add(element)
        End Sub
    End Class
 
    Public Class CustomCalculatorElement
        Inherits LightVisualElement
        Private calculatorElement As RadCalculatorDropDownElement
        Private contentElement As RadCalculatorContentElement
 
        Protected Overrides Sub CreateChildElements()
            MyBase.CreateChildElements()
 
            calculatorElement = New RadCalculatorDropDownElement()
            Me.Children.Add(calculatorElement)
            calculatorElement.ArrowButton.Visibility = ElementVisibility.Collapsed
            calculatorElement.MinSize = New System.Drawing.Size(0, 30)
 
            contentElement = calculatorElement.CalculatorContentElement
            Me.Children.Add(calculatorElement.CalculatorContentElement)
        End Sub
 
        Protected Overrides Function MeasureOverride(availableSize As SizeF) As SizeF
            Dim res As SizeF = MyBase.MeasureOverride(availableSize)
            Me.contentElement.Measure(New SizeF(availableSize.Width, availableSize.Height - calculatorElement.DesiredSize.Height))
            Return res
        End Function
 
        Protected Overrides Function ArrangeOverride(finalSize As SizeF) As SizeF
            MyBase.ArrangeOverride(finalSize)
            Me.calculatorElement.Arrange(New RectangleF(0, 0, finalSize.Width, calculatorElement.DesiredSize.Height))
            Me.contentElement.Arrange(New RectangleF(0, calculatorElement.DesiredSize.Height, finalSize.Width, finalSize.Height - calculatorElement.DesiredSize.Height))
            Return finalSize
        End Function
    End Class
 
 
 
End Class

0
Todor
Telerik team
answered on 11 Feb 2015, 10:52 AM
Hi Jorge,

Thank you for writing back.

When EditorContentElement (the textbox above buttons area) has the focus the keyboard events are not sent to the CalculatorContentElement (which makes all the calculations).
In order to move the focus to CalculatorContentElement and still to allow users to be able to copy and paste numbers from EditorContentElement I have slightly modified the previous solution I sent you. Here is â€‹CustomCalculatorElement class which you can replace.
Public Class CustomCalculatorElement
    Inherits LightVisualElement
    Private calculatorElement As RadCalculatorDropDownElement
    Private contentElement As RadCalculatorContentElement
    Private hostedTextBox As TextBox
 
    Protected Overrides Sub CreateChildElements()
        MyBase.CreateChildElements()
 
        calculatorElement = New RadCalculatorDropDownElement()
        hostedTextBox = TryCast(calculatorElement.EditorContentElement.TextBoxItem.HostedControl, TextBox)
        AddHandler hostedTextBox.MouseUp, AddressOf hostedTextBox_MouseUp
        Me.Children.Add(calculatorElement)
        calculatorElement.ArrowButton.Visibility = ElementVisibility.Collapsed
        calculatorElement.MinSize = New System.Drawing.Size(0, 30)
 
        contentElement = calculatorElement.CalculatorContentElement
        Me.Children.Add(calculatorElement.CalculatorContentElement)
    End Sub
 
    Private Sub hostedTextBox_MouseUp(sender As Object, e As MouseEventArgs)
        'this allows selecting text from the editable area so you can copy paste it
        If hostedTextBox.SelectionLength = 0 Then
            Me.contentElement.Focus()
        End If
    End Sub
 
    Protected Overrides Function MeasureOverride(availableSize As SizeF) As SizeF
        Dim res As SizeF = MyBase.MeasureOverride(availableSize)
        Me.contentElement.Measure(New SizeF(availableSize.Width, availableSize.Height - calculatorElement.DesiredSize.Height))
        Return res
    End Function
 
    Protected Overrides Function ArrangeOverride(finalSize As SizeF) As SizeF
        MyBase.ArrangeOverride(finalSize)
        Me.calculatorElement.Arrange(New RectangleF(0, 0, finalSize.Width, calculatorElement.DesiredSize.Height))
        Me.contentElement.Arrange(New RectangleF(0, calculatorElement.DesiredSize.Height, finalSize.Width, finalSize.Height - calculatorElement.DesiredSize.Height))
 
        Return finalSize
    End Function
End Class

I hope this information is useful.

Regards,
Todor Vyagov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
CalculatorDropDown
Asked by
Jorge
Top achievements
Rank 1
Answers by
Todor
Telerik team
Jorge
Top achievements
Rank 1
Share this question
or