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

Max of character at the field from string type

3 Answers 90 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
jean michel
Top achievements
Rank 1
jean michel asked on 14 Aug 2012, 06:12 PM

Hello,

Please, I need help.

How can I put a max of character in a field of string type?
 
In my data class is this way:

[DisplayName("ID:")]
[Description("ID único")]
[Category("Básico")]
[Browsable(true)]
public String Id { get; set; }


Thank you very much.

3 Answers, 1 is accepted

Sort by
0
jean michel
Top achievements
Rank 1
answered on 14 Aug 2012, 06:46 PM
Hello,

I am back because I managed to solve this way:

private void radPropertyColuna_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
        {
            try
            {
                var editorText = e.Editor as PropertyGridTextBoxEditor;

              
               if (editorText != null)
                {
                    switch (e.Item.Name)
                    {
                        case "Id":
                            editorText.MaxLength = 30;
                            break;
                    }
                }
                else
                {
                    return;
                }

            }
            catch (Exception ex)
            {
            }

        }

 

Is there another best way?

Thank you again.

0
Stefan
Telerik team
answered on 17 Aug 2012, 09:57 AM
Hi Jean,

This approach is good enough. Feel free to use it.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Tom Mieck
Top achievements
Rank 1
answered on 11 Sep 2012, 05:47 PM
Hi,
I have implemented in the same way as you in  radPropertyColuna_EditorInitiaized event, i faced lot of issues with this event.
Say assign one event or max length for the property, then if u click any of the prperty , then the same business rules will apply
i mean for all the textbox editors those events/max length properties will apply
However when am implemented the same functionality in the radPropertyColuna_EditorRequired event, it was working fine.


Tags
PropertyGrid
Asked by
jean michel
Top achievements
Rank 1
Answers by
jean michel
Top achievements
Rank 1
Stefan
Telerik team
Tom Mieck
Top achievements
Rank 1
Share this question
or