I've attached a picture from an application that I'm trying to mimic, and I"m unsure how to do this with the GridView.
1) The ellipses lookup button on a column. Basically the same display functionality as the GridViewBrowseColumn, but rather than opening an OPenFileDialog, I want to open another WinForm that I'd pass data back and forth between.
2) The alert icon in the column - alerting the user that there is some information to be displayed.
Can anyone help by pointing me in the direction of a sample that has functionality like this, or offering some ideas on how best to accomplish? Currently, I have a command column that is performing the Lookup Function, but as the user moves columns around, it may not be in the correct place, so I don't think that's the correct path.
5 Answers, 1 is accepted
Thank you for writing.
You can use a custom GridBrowseEditor editor and display a custom form. Here is a sample code snippet:
public
Form1()
{
InitializeComponent();
this
.radGridView1.EditorRequired += radGridView1_EditorRequired;
}
private
void
radGridView1_EditorRequired(
object
sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)
{
if
(
this
.radGridView1.CurrentColumn.Name ==
"CategoryName"
)
{
e.Editor =
new
MyBrowseEditor(
this
.radGridView1.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
OnBrowseButtonClick(EventArgs e)
{
EditorForm editorForm =
new
EditorForm(
this
.Value);
DialogResult result = editorForm.ShowDialog();
if
(result == DialogResult.OK)
{
this
.Value = editorForm.TextBox.Text;
}
}
}
As to the alert icon, you can use a similar approach and insert the desired element in the custom editor's children.
I hope this information helps. Should you have further questions I would be glad to help.
Dess
Telerik
Thank you - that is most helpful.
As a follow-up, how can I allow the user to type in that field, as well as use the lookup button? The use of the editor is not required in my application.
Thank you for writing back.
In order to allow the user to type inside the GridBrowseEditor, you can set the GridBrowseEditorElement.ReadOnly property to false:
public
class
MyRadBrowseEditorElement : GridBrowseEditorElement
{
private
string
editorElementColumnName;
public
MyRadBrowseEditorElement(
string
editorColumnName) :
base
()
{
this
.editorElementColumnName = editorColumnName;
this
.ReadOnly =
false
;
}
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Hello
I have below code:
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();
RadBrowseEditorElement el = editor.EditorElement
as
RadBrowseEditorElement;
if
(el !=
null
)
{
if
(!tbSubscribed)
{
tbSubscribed =
true
;
// RadTextBoxEditorElement tbElement = (RadTextBoxEditorElement)e.Editor;//tbEditor.EditorElement;
el.KeyDown -=
new
KeyEventHandler(tbElement_KeyDown);
el.KeyDown +=
new
KeyEventHandler(tbElement_KeyDown);
el.TextBoxItem.GotFocus -=
new
EventHandler(TextBoxItem_GotFocus);
el.TextBoxItem.GotFocus +=
new
EventHandler(TextBoxItem_GotFocus);
}
}
e.Editor =
new
MyBrowseEditor(editManager.GridViewElement.CurrentColumn.Name);
}
}
but doesn't call my KeyDown event by typing in GridViewBrowseColumn !!
have you any solution?
Thanks in advance for your help
Hello, Reyhane,
Your question has already been answered in the other thread you have opened on the same topic. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
Thank you for your understanding.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik