Max of character at the field from string type

4 posts, 0 answers
  1. jean michel
    jean michel avatar
    36 posts
    Member since:
    Aug 2012

    Posted 14 Aug 2012 Link to this post

    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.

  2. jean michel
    jean michel avatar
    36 posts
    Member since:
    Aug 2012

    Posted 14 Aug 2012 Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 17 Aug 2012 Link to this post

    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 >>
  5. Tom Mieck
    Tom Mieck avatar
    11 posts
    Member since:
    Aug 2012

    Posted 11 Sep 2012 Link to this post

    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.


Back to Top