How to hide "click here to add new row" option on radGridView

32 posts, 1 answers
  1. raj
    raj avatar
    3 posts
    Member since:
    Aug 2007

    Posted 14 Dec 2007 Link to this post

    I would like to hide "click here to add new row" option on radGridView.

    Thanks,
    Rajesh
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 15 Dec 2007 Link to this post

    Hello raj,

    Thank you for writing.

    You can hide "Click here to add new row" by using the designer or programmatically.
     
    If you want to use the designer, select RadGridView and in the Properties panel, navigate to the MasterGridViewTemplate property, then click the "+" sign to open a list of its subproperties and set the AllowAddNewRow property to false.

    To do this programmatically, paste the following code snippet into the Form_Load event handler:
    radGridView1.MasterGridViewTemplate.AllowAddNewRow = false

    If you have further questions, do not hesitate to contact us.

    Greetings,
    Nikolay
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Clint Tennill
    Clint Tennill avatar
    4 posts
    Member since:
    Jan 2007

    Posted 19 Dec 2007 Link to this post

    Got it.
  5. Sofia
    Sofia avatar
    8 posts
    Member since:
    Apr 2008

    Posted 03 May 2008 Link to this post

    Hi,

    Is there a way to "allow add new row" but not display the text "Click here to add new row" ?
  6. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 05 May 2008 Link to this post

    Hi Sofia,

    Thank you for bringing this question to our attention. You can set the text in this row to string.Empty by creating and using your own localization provider. Here is the sample code:

    1 public partial class Form1 : Form 
    2
    3     public Form1() 
    4     { 
    5         InitializeComponent(); 
    6         RadGridLocalizationProvider.CurrentProvider = new CustomLocalizationProvider(); 
    7     } 
    8
    9  
    10 public class CustomLocalizationProvider : RadGridLocalizationProvider 
    11
    12     public override string GetLocalizedString(string id) 
    13     { 
    14         switch (id) 
    15         { 
    16             case RadGridStringId.AddNewRowString: return string.Empty; 
    17         } 
    18  
    19         return base.GetLocalizedString(id); 
    20     } 
    21

    Please, keep in mind that this localization provider is static and will be used from that point on for all instances of RadGridView. If you'd like to go back to the original one, you need to set it back at an appropriate time in the execution of the application.

    Consult the Localization example of the RadGridView in our examples application. In the code, you'll notice that the default localization provider is restored when the form is closed.

    If you have any additional questions, please let me know.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jul 2008

    Posted 10 Aug 2008 Link to this post

    Would you mind posting the VB equivalent for the CustomLocalizationProvider?
  8. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 11 Aug 2008 Link to this post

    Hi Ryan,

    Thank you for contacting me.

    Here you are the same code in VB.Net:
    Public Partial Class Form1 
        Inherits Form 
        Public Sub New() 
            InitializeComponent() 
            RadGridLocalizationProvider.CurrentProvider = New CustomLocalizationProvider() 
        End Sub 
    End Class 
     
    Public Class CustomLocalizationProvider 
        Inherits RadGridLocalizationProvider 
        Public Overloads Overrides Function GetLocalizedString(ByVal id As StringAs String 
            Select Case id 
                Case RadGridStringId.AddNewRowString 
                    Return String.Empty 
            End Select 
     
            Return MyBase.GetLocalizedString(id) 
        End Function 
    End Class 

    You could find and use C#/VB.Net converter in all similar cases here:
    http://codechanger.com/default.aspx

    If you have other questions, do not hesitate to contact me again.

    Greetings,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Alcatraz
    Alcatraz avatar
    15 posts
    Member since:
    Mar 2010

    Posted 14 Jun 2010 Link to this post

    Hi,

    Is it possible to Align the "Click here to add new row" text to left or right?  If yes, could you please let me know the steps.

    Thanks
    Krishnan N
  10. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 16 Jun 2010 Link to this post

    Hi Krishnan,

    Thank you for writing.

    You can change the text alignment of the new row in ViewCellFormatting event. Please consider the following code snippet:
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        if (e.CellElement.RowElement is GridNewRowElement)
        {
            e.CellElement.RowElement.TextAlignment = ContentAlignment.MiddleLeft;
            if (e.CellElement is GridRowHeaderCellElement)
            {
                if (this.radGridView1.IsInEditMode)
                {
                    e.CellElement.Visibility = ElementVisibility.Visible;
                }
                else
                {
                    e.CellElement.Visibility = ElementVisibility.Hidden;
                }
            }
        }
    }

    I hope this helps. Let me know if you have any other questions.

    Regards,
    Martin Vasilev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  11. Sheraz Naseeb
    Sheraz Naseeb avatar
    22 posts
    Member since:
    Mar 2010

    Posted 13 Aug 2010 Link to this post

    Hi There,
     
    Is there any possible way to change "Click here to add new row" text to our customised text I tried the following but didnt work...

    e.CellElement.RowElement.Text = "Click here to add new order extras..."

    Many thanks,
  12. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 17 Aug 2010 Link to this post

    Hi Sheraz Naseeb,

    Thanks for writing.

    You can change the default text of new row element in the RowFormatting event:

    void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
    {
        if (e.RowElement is GridNewRowElement)
        {
            e.RowElement.Text = "My custom add new row text";
        }
    }

    I hope this helps. Let me know if you have any other questions.

    Greetings,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Sheraz Naseeb
    Sheraz Naseeb avatar
    22 posts
    Member since:
    Mar 2010

    Posted 16 Sep 2010 Link to this post

    Hi Telerik Team,

    This GridNewRowElement does not work in ViewRowFormatting event and it says "'GridNewRowElement' is a type and cannot be used as experession". I even tried to cast it as RowElement but not working. My code is as following.

    If e.RowElement Is DirectCast(e.RowElement, GridNewRowElement) Then
        e.RowElement.Text = "MyText"
    End If

    And I would like to do the same thing with my "Drag a column here to group by this column." I would like to add custom text here or may be just remove that text but still enable grouping.

    Please help,

    Many thanks,

    Sheraz
  14. Vinh
    Vinh avatar
    6 posts
    Member since:
    Aug 2010

    Posted 17 Sep 2010 Link to this post

    How do it do it for the new RadGridView for silverlight. I couldn't find a way to hide it. Thx.
  15. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 20 Sep 2010 Link to this post

    Hi guys,

    Vinh, this topic covers only RadGridView for WinForms. Please open a new thread in our Silverlight section with your questions in order to get appropriate response.

    Sheraz, please try the following code in VB:
     
    Private Sub radGridView1_ViewRowFormatting(sender As Object, e As RowFormattingEventArgs)
        If TypeOf e.RowElement Is GridNewRowElement Then
            e.RowElement.Text = "My custom add new row text"
        End If
    End Sub

    Let me know if it still does not do the job.


    Sincerely yours,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  16. Vinh
    Vinh avatar
    6 posts
    Member since:
    Aug 2010

    Posted 20 Sep 2010 Link to this post

    There's no such method as ViewRowFormatting for RadGridView (Silverlight). I will open a new thread. Thanks.
  17. Sheraz Naseeb
    Sheraz Naseeb avatar
    22 posts
    Member since:
    Mar 2010

    Posted 20 Sep 2010 Link to this post

    Hi Martin,

    Its still not working, can you please help me quick on this issue I am trying to sort it out for about a month but no luck so far.

    And also for Grouping row I would like it to show nothing as text but want the grouping enabled.

    Thanks,

    Sheraz
  18. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 Sep 2010 Link to this post

    Hi Sheraz Naseeb,

    Please find a small sample VB.Net project, which demonstrates how to customize the add new row and group panel texts, as an attachment to this message. Let me know if you still have any additional questions.

    Sincerely yours,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Sheraz Naseeb
    Sheraz Naseeb avatar
    22 posts
    Member since:
    Mar 2010

    Posted 22 Sep 2010 Link to this post

    Hello Martin,

    Thats very kind of you sending me the sample project, but unfortunately I have to say that its not working on my end. I have attached a jpg image for your reference.

    First of all the version I am using is Q1 2009, and I guess in this version we dont have "RadGridView1.GridViewElement.GroupPanelElement.Text" property so I have to comment that.

    It will be explained more when you see the image.

    Thanks,

    Sheraz
  20. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 24 Sep 2010 Link to this post

    Hello Sheraz Naseeb,

    Thank you for contacting me again.

    Now I understand that you are using an old version of RadControls and that is the reason why my project do not work on your side. I highly recommend upgrading to the latest version Q2 2010 SP2, which contains a lot of improvements and fixes. It also would allow you to change the add new row and group panel text according to your needs.

    Regards,
    Martin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. Ifdev02
    Ifdev02 avatar
    68 posts
    Member since:
    Jul 2007

    Posted 12 Oct 2010 Link to this post

    I am using the code in example but it only change text when user is in edit mode on the row "Click here to add a new row"
    The rest of the time the text wont change.

    void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
    {
        if (e.RowElement is GridNewRowElement)
        {
            e.RowElement.Text = "My custom add new row text";
        }
    }
  22. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Oct 2010 Link to this post

    Hello,

    I would suggest to use a custom RadGridLocalizationProvider to achieve this, it's the cleanest approach and also the easiest to maintain, plus you can use the same provider for multiple grids.

    You can find a sample on somewhere on top of this page, but also, following up is a sample adapted to your question:
    RadGridLocalizationProvider.CurrentProvider = new CustomLocalizationProvider();
     
    public class CustomLocalizationProvider : RadGridLocalizationProvider
    {
        public override string GetLocalizedString(string id)
        {
            switch (id)
            {
                case RadGridStringId.AddNewRowString:
                    return "My custom add new row text";
            }
     
            return base.GetLocalizedString(id);
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  23. Brian Manning
    Brian Manning avatar
    11 posts
    Member since:
    Jun 2010

    Posted 20 Oct 2010 Link to this post

    The localization angle looks interesting, but I don't think it'll work for my scenario.  I have a grid with 3 different hierarchy levels and we'd like the text to be different at each level.

    It'd be great if the e.RowElement.Text trick worked, but I'm using the latest tools (2010.2.10.914) and I can confirm that it only displays my custom text after a user has clicked in the row.  Is there a different property that I'm missing?
  24. Brian Manning
    Brian Manning avatar
    11 posts
    Member since:
    Jun 2010

    Posted 20 Oct 2010 Link to this post

    Sorry to double post, but I found a workaround:

    First you need to implement a custom GridNewRowElement:

    public class CustomGridNewRowElement : GridNewRowElement
    {
        //Prevent themes from getting all messed up
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(GridNewRowElement);
            }
        }
      
        public override void UpdateContentVisibility(bool showCells)
        {
            base.UpdateContentVisibility(showCells);
      
            if (this.Text != string.Empty)
            {
                if (this.RowInfo.HierarchyLevel == 0)
                {
                    this.Text = "Click here to add a new Level 0 Thing";
                }
                else if (this.RowInfo.HierarchyLevel == 1)
                {
                    this.Text = "Click here to add a new Level 1 Thing";
                }
                else if (this.RowInfo.HierarchyLevel == 2)
                {
                    this.Text = "Click here to add a new Level 2 Thing";
                }
            }
        }
    }

    Next you do the following either in the OnCreateRow call of a custom grid class or in the CreateRow event handler:

    if (e.RowType == typeof(GridNewRowElement))
      e.RowType = typeof(CustomGridNewRowElement);
     
    //only do this if you're using a custom GridView class
    base.OnCreateRow(sender, e);
  25. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 20 Oct 2010 Link to this post

    Hello, @Brian: Thank you for sharing your sollution with the community. I have to add something i I may, I had some bad experiences when using the CreateRow event, because of grid virtualization because the grid reuses cells, it might cause some anomalies. If you notice any kind of problems I suggest you implement and use a custom cell provider also. Honestly I prefer overriding the localization, easier to keep consistency troughout the software. Best Regards, Emanuel Varga
  26. Brian Manning
    Brian Manning avatar
    11 posts
    Member since:
    Jun 2010

    Posted 20 Oct 2010 Link to this post

    Thanks for the heads up.  I'll keep my eyes open, but I haven't seen anything suspicious yet.  It seems like that UpdateContentVisibility method gets called whenever the row gets formatted, so I'm hoping it won't be an issue.
  27. simon
    simon avatar
    3 posts
    Member since:
    Jan 2015

    Posted 07 Jan 2015 Link to this post

    Hi,

    It seems if I use the RadGridView, 
    the option "click here to add new row" is only visible after I edited the first row.
    If i use 'tab' to navigate through the cells i eventually enter a new second row.
    But at that moment the option "click here to add new row" is not available anymore.
    Is it possible to make that option ALWAYS available and make it not dissapear when i enter a new row by 'tabbing'

    thanks,
    simon


  28. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 08 Jan 2015 Link to this post

    Hi Simon,

    Thank you for writing.

    As already mentioned in some of the posts above, the availability of a GridNewRowElement is controlled by the value of the AllowAddNewRow property of the grid and by default it is set to true.

    Indeed, it is possible to reach a behavior where the text of the GridNewRowElement is missing. This might happen in a grid in which the columns are present but there are no data rows. In this case the first row becomes CurrentRow and the cells responsible for user input become visible. You can set the CurrentRow property to null and this way the text of the GridNewRowElement would be visible right after the form has been loaded.

    If this in not your exact case please provide me with some additional information so that I can reproduce it and provide you with a solution.

    Regards,
    Hristo
    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.

     
  29. Jashwanth
    Jashwanth avatar
    1 posts
    Member since:
    Feb 2015

    Posted 21 Apr 2015 Link to this post

    Is there any way to have Add New Row option at the bottom of the Grid rather having at the top?
  30. Dess
    Admin
    Dess avatar
    1607 posts

    Posted 21 Apr 2015 Link to this post

    Hello Jashwanth,

    Thank you for writing.

    You can achieve it by setting the RadGridView.AddNewRowPosition property to SystemRowPosition.Bottom.

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  31. Terje
    Terje avatar
    6 posts
    Member since:
    Oct 2013

    Posted 13 May in reply to Hristo Merdjanov Link to this post

    Hi!

    I'n my rgv I've set AllowAddNewRow  = true, but still I'm not able to cange the "add new row"-line.

    e.RowElement is never GridNewRowElement. Any sugestions? I just want to change the colors, not realy the text.

            private void rgv_RowFormatting(object sender, RowFormattingEventArgs e)
            {
                if (e.RowElement is GridNewRowElement)
                {
                    e.RowElement.Text = "My custom add new row text";
                    e.RowElement.DrawFill = true;
                    e.RowElement.BackColor = Color.Navy;
                    e.RowElement.NumberOfColors = 1;
                }
            }

Back to Top
UI for WinForms is Visual Studio 2017 Ready