Hello,
I have a unique requirement where I have to find out if a user manually entered a value in the cell or the system generated it. For example, in a cell it shows 10 as the current value and if the user typed in 10 again, the application has to know if 10 is typed in by user or not.
The cells could have any value type and so I am changing the editor in radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e). However, the handlers for the EditorElements are not being called when the user edits the cells. I am using RadComboBoxEditorElement, GridSpinEditorElement and RadTextBoxEditorElement.
Thanks
I have a unique requirement where I have to find out if a user manually entered a value in the cell or the system generated it. For example, in a cell it shows 10 as the current value and if the user typed in 10 again, the application has to know if 10 is typed in by user or not.
The cells could have any value type and so I am changing the editor in radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e). However, the handlers for the EditorElements are not being called when the user edits the cells. I am using RadComboBoxEditorElement, GridSpinEditorElement and RadTextBoxEditorElement.
private
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
var varModel = radGridView1.CurrentRow.Tag
as
VariableModel;
if
(varModel.Variable !=
null
)
{
var variableType = varModel.Variable.VariableType;
if
(varModel.Variable.VariableSelectionValueCollection.Count > 0)
{
var selValCol = varModel.Variable.VariableSelectionValueCollection;
if
(selValCol !=
null
&& selValCol.Count > 0)
// if to be shown as a dropdown // todo: vsv fix
{
var editor =
new
RadComboBoxEditor();
var elem = editor.EditorElement
as
RadComboBoxEditorElement;
elem.DropDownWidth = radGridView1.Columns[STR_ValueCol].Width + radGridView1.Columns[STR_UnitsCol].Width;
elem.DropDownStyle = RadDropDownStyle.DropDownList;
elem.MaxDropDownItems = 10;
elem.DataSource = selValCol.Select(vs => vs.Description).ToList<
string
>();
editor.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
//editor.ValueChanged += new EventHandler(editor_ValueChanged);
e.Editor = editor;
}
}
else
if
(variableType == VariableTypeEnum.Integer)
{
var editor =
new
GridSpinEditor();
var elem = editor.EditorElement
as
GridSpinEditorElement;
elem.MaxValue =
int
.MaxValue;
elem.MinValue =
int
.MinValue;
if
(varModel.Variable.Val !=
null
)
editor.Value = varModel.Variable.Val.ToInt32();
e.Editor = editor;
}
else
if
(variableType == VariableTypeEnum.Double)
// todo : capture keys to exclude text
{
e.EditorType =
typeof
(RadTextBoxEditor);
var editor =
new
RadTextBoxEditor();
var elem = editor.EditorElement
as
RadTextBoxEditorElement;
//elem.TextChanging += new TextChangingEventHandler(Editor_TextChanging);
//elem.TextChanged += new EventHandler(elem_TextChanged);
if
(varModel.Variable.Val !=
null
)
editor.Value = varModel.Variable.Val.ToDouble();
e.Editor = editor;
}
else
if
(variableType == VariableTypeEnum.Boolean)
{
var editor =
new
RadComboBoxEditor();
var elem = editor.EditorElement
as
RadComboBoxEditorElement;
elem.Items.AddRange(
new
[] {
new
RadComboBoxItem(
"True"
),
new
RadComboBoxItem(
"False"
) });
editor.Value = elem.Items.Where(ri => ri.Text.ToLower() == varModel.Variable.Val.Val.ToLower()).FirstOrDefault();
e.Editor = editor;
}
else
if
(variableType == VariableTypeEnum.String)
{
e.EditorType =
typeof
(RadTextBoxEditor);
var editor =
new
RadTextBoxEditor();
var elem = editor.EditorElement
as
RadTextBoxEditorElement;
//elem.TextChanged += new EventHandler(elem_TextChanged);
if
(varModel.Variable.Val !=
null
)
editor.Value = varModel.Variable.Val.ToString();
e.Editor = editor;
}
}
}
Thanks