31 Answers, 1 is accepted
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
Is there a way to "allow add new row" but not display the text "Click here to add new row" ?
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:
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
RadGridLocalizationProvider.CurrentProvider = new CustomLocalizationProvider(); | |
} | |
} | |
public class CustomLocalizationProvider : RadGridLocalizationProvider | |
{ | |
public override string GetLocalizedString(string id) | |
{ | |
switch (id) | |
{ | |
case RadGridStringId.AddNewRowString: return string.Empty; | |
} | |
return base.GetLocalizedString(id); | |
} | |
} |
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
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 String) As 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.
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
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.
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,
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
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
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
ViewRowFormatting
for RadGridView (Silverlight). I will open a new thread. Thanks.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
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
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
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
The rest of the time the text wont change.
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
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?
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);
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
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.
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.
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
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;
}
}
Thank you for writing.
Please make sure that you subscribe to the ViewRowFormatting event since the RowFormatting event fires only for the data rows: Row Formatting. Please check my code snippet below:
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
this
.radGridView1.DataSource =
this
.GetData();
this
.radGridView1.ViewRowFormatting += radGridView1_ViewRowFormatting;
}
private
void
radGridView1_ViewRowFormatting(
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;
}
}
}
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Hi!
Thank's for fast answer Hristo Merdjanov, I got it working now.
I also see that every post before me was talking about ViewRowFormatting, and not RowFormatting, which I was using..
i tried this
radGridView1.MasterGridViewTemplate.AllowAddNewRow = true;
And
radGridView1.AllowAddNewRow = true;;
but nothing seems to work
Hello, Kapil,
Setting the AllowAddNewRow property to true enables the new row. However, please have in mind that the "Click here to add a new row" text is shown only when the new row is NOT current:
Once the new row is selected, the text is hidden and you are expected to see the respective cells. The RadGridView.CurrentRow property controls which row is currently focused. You can set it either to null or to any of the data rows stored in the RadGridView.Rows collection. Thus, the new row text will be shown.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.