Hello,
Is there a possibility to change the value of a GridViewBrowseColumn after selecting a file with the file browser? (e.g. for replacing parts of the path with environment variables).
My current workaround for this is a editbale GridViewTextBoxColumn for the path and another GridViewCommandColumn right next to it, which opens a filebrowser for setting the value of the GridViewTextBoxColumn.
Thanks for help!
Is there a possibility to change the value of a GridViewBrowseColumn after selecting a file with the file browser? (e.g. for replacing parts of the path with environment variables).
My current workaround for this is a editbale GridViewTextBoxColumn for the path and another GridViewCommandColumn right next to it, which opens a filebrowser for setting the value of the GridViewTextBoxColumn.
Thanks for help!
4 Answers, 1 is accepted
0
Hello Alexander,
Thank you for contacting Telerik Support.
It is possible to customize the browse editor value after selecting a file via custom GridBrowseEditor. Modify the value in the custom GridBrowseEditorElement.SaveValueFromDialog method:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for contacting Telerik Support.
It is possible to customize the browse editor value after selecting a file via custom GridBrowseEditor. Modify the value in the custom GridBrowseEditorElement.SaveValueFromDialog method:
public
Form1()
{
InitializeComponent();
this
.radGridView1.EditorRequired += radGridView1_EditorRequired;
}
private
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
GridViewEditManager editManager = sender
as
GridViewEditManager;
bool
isGridBrowseEditor = e.EditorType ==
typeof
(GridBrowseEditor);
if
(isGridBrowseEditor)
{
e.Editor =
new
MyBrowseEditor(editManager.GridViewElement.CurrentColumn.Name);
}
}
public
class
MyBrowseEditor : GridBrowseEditor
{
private
string
editorColumnName;
public
MyBrowseEditor(
string
columnName) :
base
()
{
this
.editorColumnName = columnName;
}
protected
override
RadElement CreateEditorElement()
{
return
new
MyRadBrowseEditorElement(editorColumnName);
}
}
public
class
MyRadBrowseEditorElement : GridBrowseEditorElement
{
private
string
editorElementColumnName;
public
MyRadBrowseEditorElement(
string
editorColumnName) :
base
()
{
this
.editorElementColumnName = editorColumnName;
}
protected
override
void
SaveValueFromDialog()
{
//customize this.Value according to the specific requirement
if
(
this
.DialogType == BrowseEditorDialogType.OpenFileDialog)
{
OpenFileDialog dialog = Dialog
as
OpenFileDialog;
if
(dialog !=
null
)
{
this
.Value = dialog.FileName;
}
}
else
if
(
this
.DialogType == BrowseEditorDialogType.FolderBrowseDialog)
{
FolderBrowserDialog dialog = Dialog
as
FolderBrowserDialog;
if
(dialog !=
null
)
{
this
.Value = dialog.SelectedPath;
}
}
else
if
(
this
.DialogType == BrowseEditorDialogType.SaveFileDialog)
{
SaveFileDialog dialog = Dialog
as
SaveFileDialog;
if
(dialog !=
null
)
{
this
.Value = dialog.FileName;
}
}
else
if
(
this
.DialogType == BrowseEditorDialogType.FontDialog)
{
FontDialog dialog = Dialog
as
FontDialog;
if
(dialog !=
null
)
{
FontConverter fc =
new
FontConverter();
this
.Value = fc.ConvertToString(dialog.Font);
}
}
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alexander
Top achievements
Rank 1
answered on 06 Feb 2014, 06:08 AM
Thanks for the answer!
But i think I formulated my question wrong. I want the user to be able to change the path in the GridView in the UI, not programmatically.
But i think I formulated my question wrong. I want the user to be able to change the path in the GridView in the UI, not programmatically.
0
Accepted
Hello Alexander,
Thank you for writing back.
In order to enable the text box part for editing, you should set the GridBrowseEditorElement.ReadOnly property to false:
Please do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Thank you for writing back.
In order to enable the text box part for editing, you should set the GridBrowseEditorElement.ReadOnly property to false:
private
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
GridViewEditManager editManager = sender
as
GridViewEditManager;
bool
isGridBrowseEditor = e.EditorType ==
typeof
(GridBrowseEditor);
if
(isGridBrowseEditor)
{
GridBrowseEditor editor =
new
GridBrowseEditor();
GridBrowseEditorElement el = editor.EditorElement
as
GridBrowseEditorElement;
el.ReadOnly =
false
;
e.Editor = editor;
}
}
Please do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).
0
Alexander
Top achievements
Rank 1
answered on 11 Feb 2014, 11:54 AM
Thank you very much! :)
Now it works for me.
Now it works for me.