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

text box control icon

5 Answers 431 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Shafqat
Top achievements
Rank 1
Shafqat asked on 29 Nov 2017, 06:45 PM
in demo of text box control bing icon is displayed on left side of text control, i can't change that icon. there is only option for changing the background image of text box control. how to add icon in it?

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 30 Nov 2017, 11:17 AM
Hello Shafqat,

Here is how to set the icon like in the demo:
radTextBoxControl1.TextBoxElement.Image = Image.FromFile(@"C:\img\delete.png");
radTextBoxControl1.TextBoxElement.ImageAlignment = ContentAlignment.MiddleLeft;
radTextBoxControl1.TextBoxElement.ImageLayout = ImageLayout.None;
  
radTextBoxControl1.TextBoxElement.ViewElement.Padding =  new System.Windows.Forms.Padding(35, 2, 2, 0);
radTextBoxControl1.TextBoxElement.Children[1].Padding = new System.Windows.Forms.Padding(35, 2, 2, 0);

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shafqat
Top achievements
Rank 1
answered on 30 Nov 2017, 04:38 PM
the icon is not adjusting at left side of textbox control it's displayed as background of textbox control. i want to set an icon at left side of textbox control not as whole background image
0
Dimitar
Telerik team
answered on 01 Dec 2017, 07:49 AM
Hi Shafqat,

Actually, my code is different than the code in the demo application. I am using the image property and the image will be painted on the left side.

Please do not hesitate to contact us with any additional questions or concerns.  

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 1
answered on 28 Aug 2019, 03:45 AM

I see this is an old post, but it solves an design spec. I have.

in this example, how do you set focus to the textbox, such that the cursor is in the first position of the enter-able text area? 

The following places the cursor left of the image, and clearly isn't correct:

            txtUserName.TextBoxElement.Focus()

0
Nadya
Telerik team
answered on 29 Aug 2019, 04:42 AM
Hello, Mark,

According to your description I suppose that you have a RadTextBoxControl and an image on its left side. If you want the cursor to be displayed after the image you should set appropriate Padding to the TextBoxViewElemet which holds the text area. Please refer to the following code snippet which result is illustrated in the attached gif file:

radTextBoxControl1.TextBoxElement.ViewElement.Padding = new System.Windows.Forms.Padding(20, 2, 2, 0);

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TextBox
Asked by
Shafqat
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Shafqat
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Nadya
Telerik team
Share this question
or