Hi,
I've just started evaluating the RadControls for use in one of our products, to replace the standard .Net controls we currently use. I'm attempting to replicate some functionality we have in one of our existing forms. This takes the form of a general data entry form, where the make-up of the grids are based upon a configuration stored in a database. As such, each grid is built programmatically and is not bound to any objects or data.
My questions are:
I hope I've given enough information for someone to be able to help with my queries, but if I've missed something out, please let me know.
Cheers.
I've just started evaluating the RadControls for use in one of our products, to replace the standard .Net controls we currently use. I'm attempting to replicate some functionality we have in one of our existing forms. This takes the form of a general data entry form, where the make-up of the grids are based upon a configuration stored in a database. As such, each grid is built programmatically and is not bound to any objects or data.
My questions are:
- Is there a way to show a blank row for data entry as a default, rather than the "Click here to add a new row" option? Our users' primary input method is keyboard, so I would rather everything was driven from there without any need for using the mouse.
- When using a GridViewDateTimeColumn, can the time be completely hidden from view? I wish to show the date only in dd/MM/yyyy format, and I have been changing the Format, FormatString, and DataEditFormatString properties of the column to try to get this in place with no luck. Either the time is visible when in view mode, or the full (long) format for the date is used when in edit mode.
- Also date related, most of our users will be in Australia, where the standard date format is dd/MM/yyyy. However, the datetime control in the grid seems to be limiting what dates can be entered based on the current month. As an example: I want to enter the date 31/08/2010, but the current month is september, so when I type 31, it first changes the date to 3/09/2010 (as I would expect) then to 01/09/2010 (as September only has 30 days). I understand this wouldn't be an issue in the US, where the month is usually entered first, but it could cause a major issue for our users. Is there a way to get round this, either by amending some properties on the object or by intercepting some events of the control and customising the response?
- What is the best way to determine when a new row is added to the grid? On the standard control there is a UserAddedRow event. Is there an equivalent in the RadGridView?
- Can I specifically focus on a particular cell in a grid? i.e., is there an equivalent of the DataGridView.CurrentCell property?
- Can I hide columns from view while still maintaining the values? I need to be able to specify a default value for some fields that cannot be changed by the user, and previously this was done by setting the column visibility flag to False. I can't seem to find a similar property on the columns in the RadGridView.
- Lastly, do you have a guide for people migrating from the standard .Net WinForms controls to the RadControls? Something that maps the properties and events from one to the other would be a fantastic reference document.
I hope I've given enough information for someone to be able to help with my queries, but if I've missed something out, please let me know.
Cheers.
11 Answers, 1 is accepted
0
Hi Mark,
Thank you for your interest in the Telerik products. Please find the answers to your questions below:
1. You can customize the new row element in the ViewRowFormatting event:
2. In RadGridView, the cell format and the editor format are controlled by different properties. To change the cell value format of the GridViewDateTimeColumn, you should use FormatString property. To change date editor format, you have to subscribe to the CellEditorInitialized event and set the editor format there:
3. I think this issue should be avoided if the custom editor format is specified. Let me know if you still experience any difficulties with date editing.
4. To determine when a new row is added, you can use the RowsChanged or RowsChanging events:
5.RadGridView has CurrentCell, property but it is read only. To set the focus on particular cell, you should use CurrentRow and CurrentColumn properties:
6.You can hide a particular column by setting its IsVisible property to false:
7. We do not have a guide for migrating from the standard .Net controls to RadControls. You have to keep in mind that our controls extends widely the functionality of the standard ones and it is not possible to match the API in every case. However, you can learn more about our controls in the product documentation. You can also find useful our step-by-step tutorial, which contains numerous examples and scenarios concerning RadControls.
If you still has any difficulties or cannot find something in the documentation, feel free to contact our support. We will be glad to help you in the migration process.
Best wishes,
Martin Vasilev
the Telerik team
Thank you for your interest in the Telerik products. Please find the answers to your questions below:
1. You can customize the new row element in the ViewRowFormatting event:
void
radGridView1_ViewRowFormatting(
object
sender, RowFormattingEventArgs e)
{
if
(e.RowElement
is
GridNewRowElement)
{
e.RowElement.Text = String.Empty;
}
}
2. In RadGridView, the cell format and the editor format are controlled by different properties. To change the cell value format of the GridViewDateTimeColumn, you should use FormatString property. To change date editor format, you have to subscribe to the CellEditorInitialized event and set the editor format there:
void
radGridView1_CellEditorInitialized(
object
sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
RadDateTimeEditor editor =
this
.radGridView1.ActiveEditor
as
RadDateTimeEditor;
if
(editor !=
null
)
{
RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)editor.EditorElement;
editorElement.Format = DateTimePickerFormat.Custom;
editorElement.CustomFormat =
"dd.MM.yyyy"
;
}
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.radGridView1.Columns[
"OrderDate"
].FormatString =
"{0:dd.MM.yyyy}"
;
}
3. I think this issue should be avoided if the custom editor format is specified. Let me know if you still experience any difficulties with date editing.
4. To determine when a new row is added, you can use the RowsChanged or RowsChanging events:
void
radGridView1_RowsChanged(
object
sender, GridViewCollectionChangedEventArgs e)
{
if
(e.Action == NotifyCollectionChangedAction.Add)
{
//do something...
}
}
5.RadGridView has CurrentCell, property but it is read only. To set the focus on particular cell, you should use CurrentRow and CurrentColumn properties:
this
.radGridView1.CurrentRow =
this
.radGridView1.Rows[2];
this
.radGridView1.CurrentColumn =
this
.radGridView1.Columns[1];
6.You can hide a particular column by setting its IsVisible property to false:
this
.radGridView1.Columns[
"OrderDate"
].IsVisible =
false
;
7. We do not have a guide for migrating from the standard .Net controls to RadControls. You have to keep in mind that our controls extends widely the functionality of the standard ones and it is not possible to match the API in every case. However, you can learn more about our controls in the product documentation. You can also find useful our step-by-step tutorial, which contains numerous examples and scenarios concerning RadControls.
If you still has any difficulties or cannot find something in the documentation, feel free to contact our support. We will be glad to help you in the migration process.
Best wishes,
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
0
Mark
Top achievements
Rank 1
answered on 16 Sep 2010, 09:04 AM
Hi Martin,
Many thanks for your reply. You've helpd to resolve a few of my issues.
There are still a couple of things that I'm having problems with:
Point 1: The solution you provided didn't seem to alter the behaviour of the grid at all. The "Click here to add a new row" text still appears where I would expect the blank row to appear. I've managed to work around this one by adding a new row to the grid in code, so the users can start entering data immediately.
Point 3: This issue is still occurring, even with the formatting change in place. Again, I tried to find a workaround using a mask text box, but the same issue appears there when attempting to enter 31/08/2010 during the month of September.
On the whole, I'm very impressed with the RadGridView control, and I'm hoping to get approval to use it in our product, but the date entry issue in particular is causing us some concern.
Regards,
Mark
Many thanks for your reply. You've helpd to resolve a few of my issues.
There are still a couple of things that I'm having problems with:
Point 1: The solution you provided didn't seem to alter the behaviour of the grid at all. The "Click here to add a new row" text still appears where I would expect the blank row to appear. I've managed to work around this one by adding a new row to the grid in code, so the users can start entering data immediately.
Point 3: This issue is still occurring, even with the formatting change in place. Again, I tried to find a workaround using a mask text box, but the same issue appears there when attempting to enter 31/08/2010 during the month of September.
On the whole, I'm very impressed with the RadGridView control, and I'm hoping to get approval to use it in our product, but the date entry issue in particular is causing us some concern.
Regards,
Mark
0
Mark
Top achievements
Rank 1
answered on 21 Sep 2010, 04:33 AM
Hi,
Some additional questions regarding the date columns in the RadGrid.
If I don't set the null value for the column, I am unable to enter today's date via the keyboard. The value simply reverts to null if I try to do so. Is there any way round this?
Also, I have a function which sets the current cell to the first cell in the first grid on my page. 99% of the time, this will be a date control. However, the cell isn't in edit mode at this point, so if I start to type immediately, it takes three keystrokes before the control value is updated. Is there a way to programmatically cause a cell to enter edit mode? I've tried calling BeginEdit() on this cell, but this doesn't make a difference.
FYI, I'd be willing to use a Masked TextBox control for this purpose instead of a DateTime control, but I've encountered some issues with that as well. If I select a mask type of DateTime, the problem of entering a day of 31 when the current month has 30 days still exists, and if I use a standard mask type, with a mask of "##/##/####", everything works fine until the edit is complete, at which point the mask is removed and I see "########". e.g., if I enter (via the mask): "31/08/2010", when the edit is complete I see: "31082010". Again, is there any way round this problem?
Many thanks for your help.
Regards,
Mark
Some additional questions regarding the date columns in the RadGrid.
If I don't set the null value for the column, I am unable to enter today's date via the keyboard. The value simply reverts to null if I try to do so. Is there any way round this?
Also, I have a function which sets the current cell to the first cell in the first grid on my page. 99% of the time, this will be a date control. However, the cell isn't in edit mode at this point, so if I start to type immediately, it takes three keystrokes before the control value is updated. Is there a way to programmatically cause a cell to enter edit mode? I've tried calling BeginEdit() on this cell, but this doesn't make a difference.
FYI, I'd be willing to use a Masked TextBox control for this purpose instead of a DateTime control, but I've encountered some issues with that as well. If I select a mask type of DateTime, the problem of entering a day of 31 when the current month has 30 days still exists, and if I use a standard mask type, with a mask of "##/##/####", everything works fine until the edit is complete, at which point the mask is removed and I see "########". e.g., if I enter (via the mask): "31/08/2010", when the edit is complete I see: "31082010". Again, is there any way round this problem?
Many thanks for your help.
Regards,
Mark
0
Hello Mark,
Thank you for getting back to me.
I think I now understand exactly what your requirement is. However, there is no way to achieve it with RadDateTimeEditor. Still, you are on the right track using a RadMaskedBoxEditor. Actually, I have prepared a small project, which demonstrates how to change the default editor with a masked box one. You can use it as a sample and feel free to change the code and add functionality that suits your needs.
As to the begin edit cell, you can use BeginEdit method:
This code works as expected and I have demonstrated this in my sample. Please find it as an attachment to this message.
Do not hesitate to contact me again if you have any other questions.
All the best,
Martin Vasilev
the Telerik team
Thank you for getting back to me.
I think I now understand exactly what your requirement is. However, there is no way to achieve it with RadDateTimeEditor. Still, you are on the right track using a RadMaskedBoxEditor. Actually, I have prepared a small project, which demonstrates how to change the default editor with a masked box one. You can use it as a sample and feel free to change the code and add functionality that suits your needs.
As to the begin edit cell, you can use BeginEdit method:
this
.radGridView1.Rows[0].Cells[0].BeginEdit();
Do not hesitate to contact me again if you have any other questions.
All the best,
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
0
Mark
Top achievements
Rank 1
answered on 23 Sep 2010, 03:50 AM
Hi,
Many thanks for your response. This solution has allowed me to use a mask text box for date entry, and have this formatted correctly for display also.
However, the problem of immediate editing via keyboard still exists. In your provided example, typing on a cell brings up the editor, but no keystrokes are accepted until I click in the cell itself, and this is also the case when I transfer this code into my own project. I've tried calling .BeginEdit() on the cell, and the cell editor, and also tried calling .Focus() on the editor element, but this has no impact.
Is there a way round this at all? We have gone ahead and purchased a full licence for the .Net Premium collection and will, over time, be implementing this grid control throughout our product, but this is still a very important issue for us, as it could severely impact the user experience when performing keyboard-driven data entry.
Thanks for your help.
Regards,
Mark
Many thanks for your response. This solution has allowed me to use a mask text box for date entry, and have this formatted correctly for display also.
However, the problem of immediate editing via keyboard still exists. In your provided example, typing on a cell brings up the editor, but no keystrokes are accepted until I click in the cell itself, and this is also the case when I transfer this code into my own project. I've tried calling .BeginEdit() on the cell, and the cell editor, and also tried calling .Focus() on the editor element, but this has no impact.
Is there a way round this at all? We have gone ahead and purchased a full licence for the .Net Premium collection and will, over time, be implementing this grid control throughout our product, but this is still a very important issue for us, as it could severely impact the user experience when performing keyboard-driven data entry.
Thanks for your help.
Regards,
Mark
0
Mark
Top achievements
Rank 1
answered on 23 Sep 2010, 04:03 AM
Also, some additional information that I should have included in my last post. I experience a different outcome when I use a different cell type for the first cell in my grid. When I type 31082010 into my controls, I get:
There is a serious inconsistency here as I would expect all the control types to behave the same way.
Regards,
Mark
- For a GridViewTextBoxColumn, the control contains 31082010. This is the outcome I would expect, as all my keystrokes have been captured and entered into the control.
- For a GridViewMaskBoxColumn with a MaskType of Standard and a Mask of ##/##/####, the control contains 10/82/010_, as the initial keystroke (3) has been used to put the control into edit mode, but has not been transferred to the control.
- For a GridViewDateTimeColumn (converted to the custom editor as per your sample solution), the control still contains the mask of __/__/____. Only when I click in the control first do the keystrokes actually register in the control.
There is a serious inconsistency here as I would expect all the control types to behave the same way.
Regards,
Mark
0
Hello Mark,
Actually you are right that in the sample project an additional click is needed to start editing the mask editor and this could prevent keyboard data entry. Fortunately, there is an very easy way to make the editor editable directly. You have to set the focus on the RadMaskTextBox element and use its SelectAll method. I have modified my project to include that functionality.
As to your second inquiry, I did experienced the described inconsistence. I added two columns in my sample and tried the data entry and everything worked as expected.
I am attaching the modified project to this message. Please take it a look and let me know if you need any additional assistance on the topic.
Regards,
Martin Vasilev
the Telerik team
Actually you are right that in the sample project an additional click is needed to start editing the mask editor and this could prevent keyboard data entry. Fortunately, there is an very easy way to make the editor editable directly. You have to set the focus on the RadMaskTextBox element and use its SelectAll method. I have modified my project to include that functionality.
class
CustomGridMaskEditorElement : RadMaskedEditBoxElement
{
//...
public
void
SelectAllText()
{
this
.maskTextBox.Focus();
this
.maskTextBox.SelectAll();
}
//...
}
As to your second inquiry, I did experienced the described inconsistence. I added two columns in my sample and tried the data entry and everything worked as expected.
I am attaching the modified project to this message. Please take it a look and let me know if you need any additional assistance on the topic.
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
0
Mark
Top achievements
Rank 1
answered on 28 Sep 2010, 12:07 AM
Hi Martin,
Thanks for all your help in getting this sorted. It now lets me edit the mask box without clicking, but I still need to use two keystrokes to enter the first digit into the control (i.e., the first keystroke gives the mask box focus and highlights the mask, and the second enters the digit into the control).
Is there any way round this? I'm not averse to highlighting the mask on entry to the cell, or even using an internal variable to track the value of the first key pressed.
I'll keep trying different things, but if you can think of anything, that would be great.
Regards,
Mark
Thanks for all your help in getting this sorted. It now lets me edit the mask box without clicking, but I still need to use two keystrokes to enter the first digit into the control (i.e., the first keystroke gives the mask box focus and highlights the mask, and the second enters the digit into the control).
Is there any way round this? I'm not averse to highlighting the mask on entry to the cell, or even using an internal variable to track the value of the first key pressed.
I'll keep trying different things, but if you can think of anything, that would be great.
Regards,
Mark
0
Hi Mark,
Thank you for getting back to me.
I am unable to reproduce the case where an additional key-stroke is needed to begin entering a value in the customized date-time column. Could you please send me a step-by-step guidance describing how to reproduce that in my sample project? Thank you for your cooperation.
Greetings,
Martin Vasilev
the Telerik team
Thank you for getting back to me.
I am unable to reproduce the case where an additional key-stroke is needed to begin entering a value in the customized date-time column. Could you please send me a step-by-step guidance describing how to reproduce that in my sample project? Thank you for your cooperation.
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
0
Craig
Top achievements
Rank 1
answered on 10 Aug 2012, 02:43 AM
We have recently updated our controls from using the, now obsolete, RadMaskTextBox to the RadMaskedEditBox (Q2 2012) and the attached sample project does not work anymore.
I have updated the code to reflect the new control but the code throws an exception when assigned the HostedControl to the maskTextBox in the code below.
Do you have any guidance in solving this issue?
I have updated the code to reflect the new control but the code throws an exception when assigned the HostedControl to the maskTextBox in the code below.
public
class
MPXGridDateMaskEditorElement : RadMaskedEditBoxElement
{
RadMaskedEditBox maskTextBox;
DateTime? value;
public
MPXGridDateMaskEditorElement()
{
this
.maskTextBox = (RadMaskedEditBox)
this
.TextBoxItem.HostedControl;
this
.maskTextBox.MaskType = MaskType.Standard;
this
.maskTextBox.Mask =
"##/##/####"
;
}
Do you have any guidance in solving this issue?
0
Hi Craig,
Thank you for writing back.
I think that in the new version you do not need more the custom editor. Please, refer to the attached project that demonstrates the new approach.
I hope this helps.
Regards,
Peter
the Telerik team
Thank you for writing back.
I think that in the new version you do not need more the custom editor. Please, refer to the attached project that demonstrates the new approach.
I hope this helps.
Regards,
Peter
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>