Grid Lookup Column and Popup

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    21 posts
    Member since:
    Jan 2008

    Posted 14 Jan Link to this post

    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. 

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 18 Jan Link to this post

    Hello Daniel,

    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.
     
    Regards,
    Dess
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    21 posts
    Member since:
    Jan 2008

    Posted 19 Jan in reply to Dess Link to this post

    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. 

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 20 Jan Link to this post

    Hello Daniel,

    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
    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 Feedback Portal and vote to affect the priority of the items
Back to Top