10 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 10 Dec 2010, 01:38 PM
Hi Dean,
I think that this would be something that would be quite easy to make as a user control. If I get the time, I'll try and put one together for you.
All the best
Richard
I think that this would be something that would be quite easy to make as a user control. If I get the time, I'll try and put one together for you.
All the best
Richard
0
Dean
Top achievements
Rank 2
answered on 10 Dec 2010, 09:25 PM
Thanks alot Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 10 Dec 2010, 10:37 PM
Hi Dean,
Have a go with this. It's pretty simple, but an Input Box isn't too complex. It can probably be improved but it's a start. Just create a new class called RadInputBox and drop in the following code:
and call it like so...
screenshot attached.. hope this helps
Richard
Have a go with this. It's pretty simple, but an Input Box isn't too complex. It can probably be improved but it's a start. Just create a new class called RadInputBox and drop in the following code:
Imports
Telerik.WinControls
Imports
Telerik.WinControls.UI
Public
Class
RadInputBox
Shared
Function
Show(
ByVal
Prompt
As
String
,
ByVal
Title
As
String
,
Optional
ByVal
DefaultResponse
As
String
=
""
)
As
String
Dim
inputBox
As
New
RadInputBoxInternal()
inputBox.StartPosition = FormStartPosition.CenterParent
inputBox.LabelQuestion.Text = Prompt
inputBox.Text = Title
If
inputBox.ShowDialog() = DialogResult.OK
Then
Return
inputBox.TextBoxInput.Text
Else
Return
DefaultResponse
End
If
End
Function
Private
Class
RadInputBoxInternal
Inherits
Telerik.WinControls.UI.RadForm
Friend
Sub
New
()
Me
.InitializeComponent()
End
Sub
<System.Diagnostics.DebuggerNonUserCode()> _
Protected
Overrides
Sub
Dispose(
ByVal
disposing
As
Boolean
)
Try
If
disposing
AndAlso
components IsNot
Nothing
Then
components.Dispose()
End
If
Finally
MyBase
.Dispose(disposing)
End
Try
End
Sub
Private
components
As
System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> _
Private
Sub
InitializeComponent()
Me
.ButtonOk =
New
Telerik.WinControls.UI.RadButton()
Me
.ButtonCancel =
New
Telerik.WinControls.UI.RadButton()
Me
.TextBoxInput =
New
Telerik.WinControls.UI.RadTextBox()
Me
.LabelQuestion =
New
Telerik.WinControls.UI.RadLabel()
CType
(
Me
.ButtonOk, System.ComponentModel.ISupportInitialize).BeginInit()
CType
(
Me
.ButtonCancel, System.ComponentModel.ISupportInitialize).BeginInit()
CType
(
Me
.TextBoxInput, System.ComponentModel.ISupportInitialize).BeginInit()
CType
(
Me
.LabelQuestion, System.ComponentModel.ISupportInitialize).BeginInit()
CType
(
Me
, System.ComponentModel.ISupportInitialize).BeginInit()
Me
.SuspendLayout()
'
'ButtonOk
'
Me
.ButtonOk.Location =
New
System.Drawing.Point(342, 12)
Me
.ButtonOk.Name =
"ButtonOk"
Me
.ButtonOk.Size =
New
System.Drawing.Size(97, 24)
Me
.ButtonOk.TabIndex = 0
Me
.ButtonOk.Text =
"Ok"
'
'ButtonCancel
'
Me
.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me
.ButtonCancel.Location =
New
System.Drawing.Point(342, 42)
Me
.ButtonCancel.Name =
"ButtonCancel"
Me
.ButtonCancel.Size =
New
System.Drawing.Size(97, 24)
Me
.ButtonCancel.TabIndex = 1
Me
.ButtonCancel.Text =
"Cancel"
'
'TextBoxInput
'
Me
.TextBoxInput.Location =
New
System.Drawing.Point(13, 87)
Me
.TextBoxInput.Name =
"TextBoxInput"
Me
.TextBoxInput.Size =
New
System.Drawing.Size(426, 20)
Me
.TextBoxInput.TabIndex = 2
Me
.TextBoxInput.TabStop =
False
'
'LabelQuestion
'
Me
.LabelQuestion.AutoSize =
False
Me
.LabelQuestion.Location =
New
System.Drawing.Point(13, 12)
Me
.LabelQuestion.Name =
"LabelQuestion"
Me
.LabelQuestion.Size =
New
System.Drawing.Size(323, 69)
Me
.LabelQuestion.TabIndex = 3
Me
.LabelQuestion.Text =
"text"
'
'RadForm1
'
Me
.AcceptButton =
Me
.ButtonOk
Me
.AutoScaleDimensions =
New
System.Drawing.SizeF(6.0!, 13.0!)
Me
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me
.CancelButton =
Me
.ButtonCancel
Me
.ClientSize =
New
System.Drawing.Size(451, 119)
Me
.Controls.Add(
Me
.LabelQuestion)
Me
.Controls.Add(
Me
.TextBoxInput)
Me
.Controls.Add(
Me
.ButtonCancel)
Me
.Controls.Add(
Me
.ButtonOk)
Me
.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me
.MaximizeBox =
False
Me
.MinimizeBox =
False
Me
.Name =
"RadInputInternal"
'
'
'
Me
.RootElement.ApplyShapeToControl =
True
Me
.Text =
"RadInputInternal"
CType
(
Me
.ButtonOk, System.ComponentModel.ISupportInitialize).EndInit()
CType
(
Me
.ButtonCancel, System.ComponentModel.ISupportInitialize).EndInit()
CType
(
Me
.TextBoxInput, System.ComponentModel.ISupportInitialize).EndInit()
CType
(
Me
.LabelQuestion, System.ComponentModel.ISupportInitialize).EndInit()
CType
(
Me
, System.ComponentModel.ISupportInitialize).EndInit()
Me
.ResumeLayout(
False
)
Me
.PerformLayout()
End
Sub
Friend
WithEvents
ButtonOk
As
Telerik.WinControls.UI.RadButton
Friend
WithEvents
ButtonCancel
As
Telerik.WinControls.UI.RadButton
Friend
WithEvents
TextBoxInput
As
Telerik.WinControls.UI.RadTextBox
Friend
WithEvents
LabelQuestion
As
Telerik.WinControls.UI.RadLabel
Private
Sub
RadForm1_Shown(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Shown
Me
.TextBoxInput.SelectionLength = 0
Me
.TextBoxInput.Focus()
End
Sub
Private
Sub
ButtonCancel_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
ButtonCancel.Click
Me
.DialogResult = Windows.Forms.DialogResult.Cancel
Me
.Close()
End
Sub
Private
Sub
ButtonOk_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
ButtonOk.Click
Me
.DialogResult = DialogResult.OK
Me
.Close()
End
Sub
End
Class
End
Class
and call it like so...
Private
Sub
RadButton1_Click_1(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadButton1.Click
Me
.RadTextBox1.Text = RadInputBox.Show(
"What's your name?"
,
"Name"
)
End
Sub
screenshot attached.. hope this helps
Richard
JULIO CESAR
commented on 04 Aug 2022, 05:18 PM
Top achievements
Rank 1
Hola, gracias por el Tip. Como puedo agregarle Theme al RadInputBox?
Dess | Tech Support Engineer, Principal
commented on 05 Aug 2022, 04:25 AM
Telerik team
Hello, JULIO CESAR,
I would like to note that the official language for communication in this forum is English. Thank you for your understanding.
As to the question about the theme, please have in mind that the input box is actually a RadForm with several RadControls in it. Hence, you can apply one of the available themes that the Telerik UI for WinForms suite offers
https://docs.telerik.com/devtools/winforms/styling-and-appearance/using-default-themes
You can also apply a theme to the entire application:
0
Richard Slade
Top achievements
Rank 2
answered on 13 Dec 2010, 05:20 PM
Hello,
how did this go? If it helped, please remember to mark as answer.
Thanks
Richard
how did this go? If it helped, please remember to mark as answer.
Thanks
Richard
0
Dean
Top achievements
Rank 2
answered on 13 Dec 2010, 09:31 PM
Hi Richard,
Thanks a lot for your help with the Inputbox, it's much appreciated.
Thanks a lot for your help with the Inputbox, it's much appreciated.
0
Dean
Top achievements
Rank 2
answered on 13 Dec 2010, 09:33 PM
Oh, I would still like to put this forward as a suggestion to add this to the WinForms Control Set.
0
Hello guys,
@Dean - in order to create the desired component, you can follow the approach suggested by Richard. I will forward your suggestion to our development team for further discussion.
@Richard - thank you for your help. Your Telerik Points have been updated accordingly.
If there is anything else I can assist you with, do not hesitate to contact me.
Greetings,
Stefan
the Telerik team
@Dean - in order to create the desired component, you can follow the approach suggested by Richard. I will forward your suggestion to our development team for further discussion.
@Richard - thank you for your help. Your Telerik Points have been updated accordingly.
If there is anything else I can assist you with, do not hesitate to contact me.
Greetings,
Stefan
the Telerik team
0
Guy
Top achievements
Rank 1
answered on 29 Oct 2014, 01:47 PM
For this input box ,
Has anyone translate this in C# ?
regards
Has anyone translate this in C# ?
regards
0
Hi Guy,
Here is the class in C#:
and here is how to use it:
FYI you can use our free online converter to convert code between C# and VB at the following address: http://converter.telerik.com/.
I hope this helps.
Regards,
Stefan
Telerik
Here is the class in C#:
class
RadInputBox
{
public
static
string
Show(
string
Prompt,
string
Title,
string
DefaultResponse =
""
)
{
RadInputBoxInternal inputBox =
new
RadInputBoxInternal();
inputBox.StartPosition = FormStartPosition.CenterParent;
inputBox.LabelQuestion.Text = Prompt;
inputBox.Text = Title;
if
(inputBox.ShowDialog() == DialogResult.OK)
{
return
inputBox.TextBoxInput.Text;
}
else
{
return
DefaultResponse;
}
}
private
class
RadInputBoxInternal : Telerik.WinControls.UI.RadForm
{
internal
RadInputBoxInternal()
{
Shown += RadForm1_Shown;
this
.InitializeComponent();
}
[System.Diagnostics.DebuggerNonUserCode()]
protected
override
void
Dispose(
bool
disposing)
{
try
{
if
(disposing && components !=
null
)
{
components.Dispose();
}
}
finally
{
base
.Dispose(disposing);
}
}
private
System.ComponentModel.IContainer components;
[System.Diagnostics.DebuggerStepThrough()]
private
void
InitializeComponent()
{
this
.ButtonOk =
new
Telerik.WinControls.UI.RadButton();
this
.ButtonCancel =
new
Telerik.WinControls.UI.RadButton();
this
.TextBoxInput =
new
Telerik.WinControls.UI.RadTextBox();
this
.LabelQuestion =
new
Telerik.WinControls.UI.RadLabel();
((System.ComponentModel.ISupportInitialize)
this
.ButtonOk).BeginInit();
((System.ComponentModel.ISupportInitialize)
this
.ButtonCancel).BeginInit();
((System.ComponentModel.ISupportInitialize)
this
.TextBoxInput).BeginInit();
((System.ComponentModel.ISupportInitialize)
this
.LabelQuestion).BeginInit();
((System.ComponentModel.ISupportInitialize)
this
).BeginInit();
this
.SuspendLayout();
//
//ButtonOk
//
this
.ButtonOk.Location =
new
System.Drawing.Point(342, 12);
this
.ButtonOk.Name =
"ButtonOk"
;
this
.ButtonOk.Size =
new
System.Drawing.Size(97, 24);
this
.ButtonOk.TabIndex = 0;
this
.ButtonOk.Text =
"Ok"
;
//
//ButtonCancel
//
this
.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this
.ButtonCancel.Location =
new
System.Drawing.Point(342, 42);
this
.ButtonCancel.Name =
"ButtonCancel"
;
this
.ButtonCancel.Size =
new
System.Drawing.Size(97, 24);
this
.ButtonCancel.TabIndex = 1;
this
.ButtonCancel.Text =
"Cancel"
;
//
//TextBoxInput
//
this
.TextBoxInput.Location =
new
System.Drawing.Point(13, 87);
this
.TextBoxInput.Name =
"TextBoxInput"
;
this
.TextBoxInput.Size =
new
System.Drawing.Size(426, 20);
this
.TextBoxInput.TabIndex = 2;
this
.TextBoxInput.TabStop =
false
;
//
//LabelQuestion
//
this
.LabelQuestion.AutoSize =
false
;
this
.LabelQuestion.Location =
new
System.Drawing.Point(13, 12);
this
.LabelQuestion.Name =
"LabelQuestion"
;
this
.LabelQuestion.Size =
new
System.Drawing.Size(323, 69);
this
.LabelQuestion.TabIndex = 3;
this
.LabelQuestion.Text =
"text"
;
//
//RadForm1
//
this
.AcceptButton =
this
.ButtonOk;
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6f, 13f);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.CancelButton =
this
.ButtonCancel;
this
.ClientSize =
new
System.Drawing.Size(451, 119);
this
.Controls.Add(
this
.LabelQuestion);
this
.Controls.Add(
this
.TextBoxInput);
this
.Controls.Add(
this
.ButtonCancel);
this
.Controls.Add(
this
.ButtonOk);
this
.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this
.MaximizeBox =
false
;
this
.MinimizeBox =
false
;
this
.Name =
"RadInputInternal"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"RadInputInternal"
;
((System.ComponentModel.ISupportInitialize)
this
.ButtonOk).EndInit();
((System.ComponentModel.ISupportInitialize)
this
.ButtonCancel).EndInit();
((System.ComponentModel.ISupportInitialize)
this
.TextBoxInput).EndInit();
((System.ComponentModel.ISupportInitialize)
this
.LabelQuestion).EndInit();
((System.ComponentModel.ISupportInitialize)
this
).EndInit();
this
.ResumeLayout(
false
);
this
.PerformLayout();
}
private
Telerik.WinControls.UI.RadButton withEventsField_ButtonOk;
internal
Telerik.WinControls.UI.RadButton ButtonOk
{
get
{
return
withEventsField_ButtonOk; }
set
{
if
(withEventsField_ButtonOk !=
null
)
{
withEventsField_ButtonOk.Click -= ButtonOk_Click;
}
withEventsField_ButtonOk = value;
if
(withEventsField_ButtonOk !=
null
)
{
withEventsField_ButtonOk.Click += ButtonOk_Click;
}
}
}
private
Telerik.WinControls.UI.RadButton withEventsField_ButtonCancel;
internal
Telerik.WinControls.UI.RadButton ButtonCancel
{
get
{
return
withEventsField_ButtonCancel; }
set
{
if
(withEventsField_ButtonCancel !=
null
)
{
withEventsField_ButtonCancel.Click -= ButtonCancel_Click;
}
withEventsField_ButtonCancel = value;
if
(withEventsField_ButtonCancel !=
null
)
{
withEventsField_ButtonCancel.Click += ButtonCancel_Click;
}
}
}
internal
Telerik.WinControls.UI.RadTextBox TextBoxInput;
internal
Telerik.WinControls.UI.RadLabel LabelQuestion;
private
void
RadForm1_Shown(System.Object sender, System.EventArgs e)
{
this
.TextBoxInput.SelectionLength = 0;
this
.TextBoxInput.Focus();
}
private
void
ButtonCancel_Click(System.Object sender, System.EventArgs e)
{
this
.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this
.Close();
}
private
void
ButtonOk_Click(System.Object sender, System.EventArgs e)
{
this
.DialogResult = DialogResult.OK;
this
.Close();
}
}
}
and here is how to use it:
this
.radTextBox1.Text = RadInputBox.Show(
"What is your name?"
,
"Name"
);
FYI you can use our free online converter to convert code between C# and VB at the following address: http://converter.telerik.com/.
I hope this helps.
Regards,
Stefan
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
Guy
Top achievements
Rank 1
answered on 30 Oct 2014, 08:51 AM
HI Stefan,
That's great.
Thanks for the converter tip ! Very useful !
Regards .
Guy
That's great.
Thanks for the converter tip ! Very useful !
Regards .
Guy