Chris Gethin
Top achievements
Rank 1
Chris Gethin
asked on 24 May 2012, 02:27 PM
Hi,
Is it possible to set a PropertyGridTextBoxEditor to be multiline?
I have tried the following approach, but although the Multiline property does successfully get set to true, the textbox does not display as such.
Is it possible to set a PropertyGridTextBoxEditor to be multiline?
I have tried the following approach, but although the Multiline property does successfully get set to true, the textbox does not display as such.
private void detailsPropertyGrid_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e) { switch (e.Item.Name) { case "Details": PropertyGridTextBoxEditor editor = e.Editor as PropertyGridTextBoxEditor; editor.Multiline = true; break; default: return; } }Thanks,
Chris.
5 Answers, 1 is accepted
0
Hello Chris,
Thank you for writing.
The RadPropertyGrid items have a fixed size and they cannot be resized to take a multiline text box. You can create a custom editor to show a bigger element containing a multiline text box. You can read more on creating a custom editor in out online documentation.
I hope this will be useful. If you have further questions, I would be glad to help.
All the best,
Ivan Petrov
the Telerik team
Thank you for writing.
The RadPropertyGrid items have a fixed size and they cannot be resized to take a multiline text box. You can create a custom editor to show a bigger element containing a multiline text box. You can read more on creating a custom editor in out online documentation.
I hope this will be useful. If you have further questions, I would be glad to help.
All the best,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Andreas
Top achievements
Rank 1
answered on 28 Dec 2017, 11:46 PM
Is there still no other possibility to create Multiline Textbox?
0
Hello, Andreas,
Thank you for writing.
In order to enable multiline PropertyGridTextBoxEditor you can refer to the following code snippet:

I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Thank you for writing.
In order to enable multiline PropertyGridTextBoxEditor you can refer to the following code snippet:
public RadForm1(){ InitializeComponent(); this.radPropertyGrid1.SelectedObject = new Item(123, "First row" + Environment.NewLine + "Second row",DateTime.Now ); this.radPropertyGrid1.EditorInitialized+=radPropertyGrid1_EditorInitialized; this.radPropertyGrid1.ItemHeight = 50;}private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e){ PropertyGridTextBoxEditor editor = e.Editor as PropertyGridTextBoxEditor; if (editor!=null) { editor.Multiline = true; }}public class Item{ public int Id { get; set; } public string Name { get; set; } public DateTime CreatedOn { get; set; } public Item(int id, string name, DateTime createdOn) { this.Id = id; this.Name = name; this.CreatedOn = createdOn; }}I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
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
Andreas
Top achievements
Rank 1
answered on 04 Jan 2018, 09:19 AM
works fine. But how can I add more than 1 Multiline Item to property grid?
Is it possible to add lines by List for example?
0
Hello, Andreas,
Thank you for writing.
Each property of the RadPropertyGrid.SelectedObject is displayed as a PropertyGridItem. You can add as many string properties as you wish that contain multiline data. However, if you have a property of type List<string> and want to display it as multiline text and edit this text, you can use a custom TypeConverter. I have prepared a sample code snippet which result is illustrated in the attached gif file:
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Thank you for writing.
Each property of the RadPropertyGrid.SelectedObject is displayed as a PropertyGridItem. You can add as many string properties as you wish that contain multiline data. However, if you have a property of type List<string> and want to display it as multiline text and edit this text, you can use a custom TypeConverter. I have prepared a sample code snippet which result is illustrated in the attached gif file:
public partial class RadForm1 : Telerik.WinControls.UI.RadForm{ public RadForm1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = new Item(123, "First row" + Environment.NewLine + "Second row",DateTime.Now); this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized; this.radPropertyGrid1.ItemHeight = 50; } private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridTextBoxEditor editor = e.Editor as PropertyGridTextBoxEditor; if (editor != null) { editor.Multiline = true; } } public class Item { public int Id { get; set; } public string Name { get; set; } public DateTime CreatedOn { get; set; } [Editor(typeof(PropertyGridTextBoxEditor), typeof(BaseInputEditor))] [TypeConverter(typeof(MyTypeConverter))] public List<string> TextItems { get; set; } public Item(int id, string name, DateTime createdOn) { this.Id = id; this.Name = name; this.CreatedOn = createdOn; this.TextItems = new List<string>() { "one", "two", "three" }; } } public class MyTypeConverter:TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(string)) { return true; } return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { List<string> textItems = value as List<string>; if (textItems != null) { return String.Join(Environment.NewLine, textItems); } return true; } return base.ConvertTo(context, culture, value, destinationType); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return new List<string>(); } string text = value.ToString(); string[] tokens = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); return tokens.ToList(); } }}I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
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.
