
Lucas Aguiar
Top achievements
Rank 1
Lucas Aguiar
asked on 06 Apr 2011, 05:16 AM
Difficulty in small things in RadGridView:
Why can not I pinned the first two columns?
In columns with decimal type, edit them to {0 :###,## 0:00, pressing the comma, a second comma is placed in value. I have to use dot "." to work.
After placing a column in edit mode, I would like to press the down arrow to move it to the next line without the need to press enter to confirm.
We purchase components from Telerik and do not use almost nothing because of trouble setting things simple
Why can not I pinned the first two columns?
In columns with decimal type, edit them to {0 :###,## 0:00, pressing the comma, a second comma is placed in value. I have to use dot "." to work.
After placing a column in edit mode, I would like to press the down arrow to move it to the next line without the need to press enter to confirm.
We purchase components from Telerik and do not use almost nothing because of trouble setting things simple
13 Answers, 1 is accepted
0

Richard Slade
Top achievements
Rank 2
answered on 06 Apr 2011, 09:52 AM
Hello,
You can pin multiple columns in RadGridView. For exmaple:
For more information on pinning column, please visit this help topic
With regards to your second point, perhaps you could expand a little on your explanation which will help me to assist you.
For your third question, some column types do allow you to press the down arrow to move to another cell, such as the GridViewTextBoxColumn. Some other columns such as those containing a RadDropDownListEditor or SpinEditor by design allow the user to use the keyboard to navigate the editor; E.g. moving up and down selected items in a RadDropDownList and changing a decimal value up and down in a Spin Editor.
I hope this helps, but let me know if you need further help
Richard
You can pin multiple columns in RadGridView. For exmaple:
this
.radGridView1.Columns[
"Id"
].PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left;
this
.radGridView1.Columns[
"MyDate"
].PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left;
With regards to your second point, perhaps you could expand a little on your explanation which will help me to assist you.
For your third question, some column types do allow you to press the down arrow to move to another cell, such as the GridViewTextBoxColumn. Some other columns such as those containing a RadDropDownListEditor or SpinEditor by design allow the user to use the keyboard to navigate the editor; E.g. moving up and down selected items in a RadDropDownList and changing a decimal value up and down in a Spin Editor.
I hope this helps, but let me know if you need further help
Richard
0

Lucas Aguiar
Top achievements
Rank 1
answered on 06 Apr 2011, 12:46 PM
I would like the same behavior when navegate dagridview original and edited data.
After editing a cell and navigate to another cell, I would like the automatically end edit cell.
That a cell from being edited only when I use the keyboard but no mouse.
That columns of type decimal, when I enter the decimal separator in my case, "," does not appear like this: 123,, 30 but 123,30.
{0:###,##0,00}
I set the first two columns for property builder IsPinned = true but the columns do not get frozen
thanks
After editing a cell and navigate to another cell, I would like the automatically end edit cell.
That a cell from being edited only when I use the keyboard but no mouse.
That columns of type decimal, when I enter the decimal separator in my case, "," does not appear like this: 123,, 30 but 123,30.
{0:###,##0,00}
I set the first two columns for property builder IsPinned = true but the columns do not get frozen
thanks
0

Lucas Aguiar
Top achievements
Rank 1
answered on 07 Apr 2011, 01:15 AM
Hello Telerik,
I do not believe that a control as rich as the GridView is complicated as decimal format a cell.
I created the column as decimal to 3 decimal places.
Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn1 Telerik.WinControls.UI.GridViewDecimalColumn = new ();
gridViewDecimalColumn1.AllowGroup = false;
gridViewDecimalColumn1.DataType = typeof (decimal);
gridViewDecimalColumn1.DecimalPlaces = 3;
gridViewDecimalColumn1.FieldAlias = "Produto.PrecoPromocional";
gridViewDecimalColumn1.FieldName = "Produto.PrecoPromocional";
gridViewDecimalColumn1.FormatInfo = new System.Globalization.CultureInfo ("en");
gridViewDecimalColumn1.FormatString = "{0: N3}";
gridViewDecimalColumn1.HeaderText = "value";
gridViewDecimalColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleRight;
gridViewDecimalColumn1.ShowUpDownButtons = false;
gridViewDecimalColumn1.Step = new decimal (new int [] {
0,
0,
0,
0});
gridViewDecimalColumn1.ThousandsSeparator = true;
gridViewDecimalColumn1.UniqueName = "valorPromocao";
gridViewDecimalColumn1.VisibleInColumnChooser = false;
I do not believe that a control as rich as the GridView is complicated as decimal format a cell.
I created the column as decimal to 3 decimal places.
Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn1 Telerik.WinControls.UI.GridViewDecimalColumn = new ();
gridViewDecimalColumn1.AllowGroup = false;
gridViewDecimalColumn1.DataType = typeof (decimal);
gridViewDecimalColumn1.DecimalPlaces = 3;
gridViewDecimalColumn1.FieldAlias = "Produto.PrecoPromocional";
gridViewDecimalColumn1.FieldName = "Produto.PrecoPromocional";
gridViewDecimalColumn1.FormatInfo = new System.Globalization.CultureInfo ("en");
gridViewDecimalColumn1.FormatString = "{0: N3}";
gridViewDecimalColumn1.HeaderText = "value";
gridViewDecimalColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleRight;
gridViewDecimalColumn1.ShowUpDownButtons = false;
gridViewDecimalColumn1.Step = new decimal (new int [] {
0,
0,
0,
0});
gridViewDecimalColumn1.ThousandsSeparator = true;
gridViewDecimalColumn1.UniqueName = "valorPromocao";
gridViewDecimalColumn1.VisibleInColumnChooser = false;
It displays the information correctly but when I try to change it does not select the entire contents of the cell so that I can override the entire value.
Example: when edit 123,35 appears ,000.
Another question: When entering a value in a cell and confirm, I would like to navigate to other cells they are not in edit mode. I only edit when I start typing something on the keyboard.
Please, I need to deliver the project to the client and just missing it.
Example: when edit 123,35 appears ,000.
Another question: When entering a value in a cell and confirm, I would like to navigate to other cells they are not in edit mode. I only edit when I start typing something on the keyboard.
Please, I need to deliver the project to the client and just missing it.
0

Emanuel Varga
Top achievements
Rank 1
answered on 07 Apr 2011, 08:23 AM
Hello Lucas,
Please take a look at the attached example, maybe this is more complex than you need but from what i understood it should do mostly everything you need.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Please take a look at the attached example, maybe this is more complex than you need but from what i understood it should do mostly everything you need.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Emanuel Varga
Top achievements
Rank 1
answered on 07 Apr 2011, 08:34 AM
Hello again,
Sorry, i forgot to add the example :(
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Sorry, i forgot to add the example :(
using
System;
using
System.Collections.Generic;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
using
Telerik.WinControls.UI.Export;
public
partial
class
Form1 : Form
{
private
RadGridView radGridView1;
private
List<User> users;
public
Form1()
{
InitializeComponent();
this
.Controls.Add(radGridView1 =
new
RadGridView());
radGridView1.Dock = DockStyle.Fill;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.CellEditorInitialized +=
new
GridViewCellEventHandler(radGridView1_CellEditorInitialized);
radGridView1.DataBindingComplete +=
new
GridViewBindingCompleteEventHandler(radGridView1_DataBindingComplete);
users =
new
List<User>();
for
(
int
i = 0; i < 10; i++)
{
var user =
new
User
{
Id = i,
Name =
"Name"
+ i,
Details =
"Bla bla bla "
+ i
};
users.Add(user);
if
(i % 2 == 0)
{
user.Date = DateTime.Now.AddMonths(i);
}
}
radGridView1.DataSource = users;
var button =
new
RadButton();
button.Text =
"Export me!"
;
button.Click +=
new
EventHandler(button_Click);
button.Dock = DockStyle.Bottom;
this
.Controls.Add(button);
}
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
if
(e.ActiveEditor
is
GridSpinEditor)
{
var editor = e.ActiveEditor
as
GridSpinEditor;
var editorElement = editor.EditorElement
as
GridSpinEditorElement;
editorElement.KeyDown -=
new
KeyEventHandler(editorElement_KeyDown);
editorElement.KeyDown +=
new
KeyEventHandler(editorElement_KeyDown);
editorElement.Disposed -=
new
EventHandler(editorElement_Disposed);
editorElement.Disposed +=
new
EventHandler(editorElement_Disposed);
}
}
void
editorElement_Disposed(
object
sender, EventArgs e)
{
var editorElement = sender
as
GridSpinEditorElement;
editorElement.KeyDown -=
new
KeyEventHandler(editorElement_KeyDown);
editorElement.Disposed -=
new
EventHandler(editorElement_Disposed);
}
void
editorElement_KeyDown(
object
sender, KeyEventArgs e)
{
switch
(e.KeyData)
{
case
Keys.Down:
this
.radGridView1.GridNavigator.SelectNextRow(1);
break
;
case
Keys.Up:
this
.radGridView1.GridNavigator.SelectPreviousRow(1);
break
;
}
}
void
radGridView1_DataBindingComplete(
object
sender, GridViewBindingCompleteEventArgs e)
{
var gridViewDecimalColumn1 = radGridView1.Columns[
"Id"
]
as
GridViewDecimalColumn;
gridViewDecimalColumn1.AllowGroup =
false
;
gridViewDecimalColumn1.DataType =
typeof
(
decimal
);
gridViewDecimalColumn1.DecimalPlaces = 3;
gridViewDecimalColumn1.FormatInfo =
new
System.Globalization.CultureInfo(
"en-US"
);
gridViewDecimalColumn1.FormatString =
"{0:N3}"
;
gridViewDecimalColumn1.HeaderText =
"value"
;
gridViewDecimalColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleRight;
gridViewDecimalColumn1.ShowUpDownButtons =
false
;
gridViewDecimalColumn1.Step =
new
decimal
(
new
int
[] {
0,
0,
0,
0});
gridViewDecimalColumn1.ThousandsSeparator =
true
;
gridViewDecimalColumn1.VisibleInColumnChooser =
false
;
}
void
button_Click(
object
sender, EventArgs e)
{
var exporter =
new
ExportToExcelML(
this
.radGridView1);
exporter.ExportVisualSettings =
true
;
exporter.SheetMaxRows = ExcelMaxRows._1048576;
exporter.SheetName =
"Sheet"
;
string
fileName =
"C:\\ExportedData123.xls"
;
this
.radGridView1.Columns[
"Date"
].ExcelExportType = DisplayFormatType.ShortDate;
// or for custom formats
// this.radGridView1.Columns["Date"].ExcelExportType = DisplayFormatType.Custom;
// this.radGridView1.Columns["Date"].ExcelExportFormatString = "dddd, dd.MM.yyyy";
exporter.RunExport(fileName);
}
}
public
class
CustomGridBehavior : BaseGridBehavior
{
public
override
bool
ProcessKey(KeyEventArgs keys)
{
if
(!
this
.GridControl.IsInEditMode || (keys.KeyData != Keys.Left && keys.KeyData != Keys.Right && keys.KeyData != Keys.Up && keys.KeyData != Keys.Down))
{
return
base
.ProcessKey(keys);
}
keys.Handled =
true
;
keys.SuppressKeyPress =
true
;
switch
(keys.KeyData)
{
case
Keys.Down:
return
this
.GridControl.GridNavigator.SelectNextRow(1);
case
Keys.Left:
return
this
.GridControl.GridNavigator.SelectPreviousColumn();
case
Keys.Right:
return
this
.GridControl.GridNavigator.SelectNextColumn();
case
Keys.Up:
return
this
.GridControl.GridNavigator.SelectPreviousRow(1);
default
:
return
base
.ProcessKey(keys);
}
}
}
public
class
User
{
public
decimal
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
Details
{
get
;
set
;
}
public
DateTime? Date
{
get
;
set
;
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Lucas Aguiar
Top achievements
Rank 1
answered on 07 Apr 2011, 09:50 PM
Thanks for replay but I think too complicated to do simple things that the framework makes the Grid without any special configuration. I have deadlines to deliver the project and I can not do trivial things. I love the Telerik, the controls have many wonderful resources but I can not wait any longer. I gave up using this control to edit information they need for numbers, primarily decimal types.
thanks
thanks
0
Hi Lucas Aguiar,
You are right that some scenarios need to be implemented not in a very straight way. However you have to keep in mind that your scenario is not a typical and differs from our default behaviour. Also there is a trade off between easiness of setting up and feature richness. As much flexibility you have as more the things goes complex.
Still I think Emanuel has provided here a quite good solution. Please could you confirm whether it works for you. Do not hesitate to write back if you experience any additional difficulties with implementing your requirements using Telerik RadControls
Greetings,
Martin Vasilev
the Telerik team
You are right that some scenarios need to be implemented not in a very straight way. However you have to keep in mind that your scenario is not a typical and differs from our default behaviour. Also there is a trade off between easiness of setting up and feature richness. As much flexibility you have as more the things goes complex.
Still I think Emanuel has provided here a quite good solution. Please could you confirm whether it works for you. Do not hesitate to write back if you experience any additional difficulties with implementing your requirements using Telerik RadControls
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

Lucas Aguiar
Top achievements
Rank 1
answered on 08 Apr 2011, 06:53 PM
Again thank you for the reply.
I could not deploy the solution of Emmanuel. In the code snippet:
radGridView1_CellEditorInitialized void (object sender, GridViewCellEventArgs e)
{
if (e.ActiveEditor is GridSpinEditor)
{
var editor = e.ActiveEditor the GridSpinEditor;
var = editorElement editor.EditorElement the GridSpinEditorElement;
editorElement.KeyDown -= new KeyEventHandler (editorElement_KeyDown);
editorElement.KeyDown + = new KeyEventHandler (editorElement_KeyDown);
editorElement.Disposed -= new EventHandler (editorElement_Disposed);
editorElement.Disposed + = new EventHandler (editorElement_Disposed);
}
}
He says he does not exist ActiveEditor in e.
Were performed using C # 2.0 VS2005.
thanks
I could not deploy the solution of Emmanuel. In the code snippet:
radGridView1_CellEditorInitialized void (object sender, GridViewCellEventArgs e)
{
if (e.ActiveEditor is GridSpinEditor)
{
var editor = e.ActiveEditor the GridSpinEditor;
var = editorElement editor.EditorElement the GridSpinEditorElement;
editorElement.KeyDown -= new KeyEventHandler (editorElement_KeyDown);
editorElement.KeyDown + = new KeyEventHandler (editorElement_KeyDown);
editorElement.Disposed -= new EventHandler (editorElement_Disposed);
editorElement.Disposed + = new EventHandler (editorElement_Disposed);
}
}
He says he does not exist ActiveEditor in e.
Were performed using C # 2.0 VS2005.
thanks
0
Hi Lucas Aguiar,
Thank you for getting back to me.
I have tried the quoted code and it works as expected on my side. Are you using the latest version Q1 2011 (2011.1.11.315) ? If not I highly recommend you to download and give it a try.
Let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Thank you for getting back to me.
I have tried the quoted code and it works as expected on my side. Are you using the latest version Q1 2011 (2011.1.11.315) ? If not I highly recommend you to download and give it a try.
Let me know if you have any additional 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
0

Iftakhar
Top achievements
Rank 1
answered on 03 May 2011, 11:48 AM
Hi,
I am trying to capture KeyDown event of Editor element. changed my code as per the example below.
but not able to capture editorElement_Disposed event. Please help. thanks
I am trying to capture KeyDown event of Editor element. changed my code as per the example below.
editorElement.Disposed -=
new
EventHandler(editorElement_Disposed);
editorElement.Disposed +=
new
EventHandler(editorElement_Disposed);
but not able to capture editorElement_Disposed event. Please help. thanks
0

Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 11:53 AM
Hello,
The editor element is not disposed every time the editor is closed, the grid reuses editors so, this could just mean that the editor hasn't been disposed yet.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
The editor element is not disposed every time the editor is closed, the grid reuses editors so, this could just mean that the editor hasn't been disposed yet.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Iftakhar
Top achievements
Rank 1
answered on 03 May 2011, 11:58 AM
thanks for the quick help..
Also, I have 2 text columns in my grid.. for 1st col I want the editor background color say light blue and for the 2nd I want white.
So I put the code editorElement.TextBoxItem.BackColor = Color.FromArgb(217, 255, 255) in CellEditorInitialized event for the first col and BackColor = Color.White for the 2nd Col.
Now when I click 1st Col to edit the back color flickers from white to light blue similarly when I click on 2nd col to edit backcolor flickers from lightblue to white. So can you please suggest what is the best way to do this.. thanks in advance..
Also, I have 2 text columns in my grid.. for 1st col I want the editor background color say light blue and for the 2nd I want white.
So I put the code editorElement.TextBoxItem.BackColor = Color.FromArgb(217, 255, 255) in CellEditorInitialized event for the first col and BackColor = Color.White for the 2nd Col.
Now when I click 1st Col to edit the back color flickers from white to light blue similarly when I click on 2nd col to edit backcolor flickers from lightblue to white. So can you please suggest what is the best way to do this.. thanks in advance..
0
Hi Iftakhar,
Probably, you would like to use the CellBeginEdit event instead CellEditorInitialized, since the same editor is reused on the next cell. Please try the following code and let me know if it does not suit to your scenario:
All the best,
Martin Vasilev
the Telerik team
Probably, you would like to use the CellBeginEdit event instead CellEditorInitialized, since the same editor is reused on the next cell. Please try the following code and let me know if it does not suit to your scenario:
void
radGridView1_CellBeginEdit(
object
sender, GridViewCellCancelEventArgs e)
{
RadTextBoxEditor editor = e.ActiveEditor
as
RadTextBoxEditor;
if
(editor !=
null
)
{
RadTextBoxEditorElement editorElement = (RadTextBoxEditorElement)editor.EditorElement;
if
(e.ColumnIndex == 0)
{
editorElement.TextBoxItem.BackColor = Color.Yellow;
}
else
if
(e.ColumnIndex == 1)
{
editorElement.TextBoxItem.BackColor = Color.LightGreen;
}
else
{
editorElement.TextBoxItem.BackColor = Color.White;
}
}
}
All the best,
Martin Vasilev
the Telerik team