This project is read-only.

DataGrid to show Edit Dialog on DoubleClick

Jun 22, 2009 at 9:02 PM

Hi there!


I'm using a Datagrid and have successfully bound my Data with a BoundList. Now I want to implement the following behaviour:

On DoubleClick a Dialog opens, displays the currently selected entry for editing with multiple field. The user has now the possibility to edit all object fields and click OK when done.

Think about the Outlook Task edit dialog for example: You have a task list with only a few columns, on doubleclick an edit dialog with all fields opens.

Is this possible and how? I only found Example26 which uses a cell-value, but not the whole object displayed in the clicked row.


Any help is appreciated, thanks in advance,


Jun 23, 2009 at 7:14 AM

Yes it is.

However, i am not sure what is the problem.

Jun 23, 2009 at 5:25 PM

My problem is the following - how do I get the DataObject bound to the line that was doubleclicked. I think I'm overlooking something, but up until now I only found the property .Value or .DisplayText for the clicked cell. How do I get the object behind the line?

Jun 24, 2009 at 10:18 AM

AFAIK, this is probably not the best option, but you can use grid.Selection.GetSelectedRows to get the rows, that are selected.

Then in grid.Selection class there should be a method, which returns row indexes for selected rows. Those indexes can be used to obtain DataObject from the list, that you have binded to the grid.

I have no SourceCode here, so can not tell exact methods to call, but the idea should be as i described.

Jun 24, 2009 at 11:15 AM
Edited Jun 24, 2009 at 11:16 AM

may be you asking about :

  int[] indexRow = grid1.Selection.GetSelectionRegion().GetRowsIndex();
  int[] indexCol = grid1.Selection.GetSelectionRegion().GetColumnsIndex();
  if (indexRow.Length > 0 && indexCol.Length >0) ;
//do your work :)


Feb 20, 2013 at 5:57 AM
In my case, I wrote ExternalEditor as a base class.

I needed to show dialog for child view editing.
using System;
using System.Windows.Forms;

namespace SourceGrid.Cells.Editors {
    /// <summary>
    /// Represents the base class of a DataModel. This DataModel support conversion but doesn't provide any user interface editor.
    /// </summary>
    public class ExternalEditor : EditorBase {
        public ExternalEditor(Type p_Type)
            : base(p_Type) {


        internal override void InternalStartEdit(SourceGrid.CellContext cellContext) {

        public virtual void StartEdit(CellContext cellContext) { }
ExternalEditor must be contained in SourceGrid source code, because InternalStartEdit is "internal" protected.

Here is inherited editor class for example.
    public class WorkmEditor : ExternalEditor {
        public DataRelation Rel { get; set; }

        public WorkmEditor(Type p_Type)
            : base(p_Type) {


        public override void StartEdit(CellContext cellContext) {
            SourceGrid.DataGrid grid = (SourceGrid.DataGrid)cellContext.Grid;

            PropertyDescriptor prop = grid.Columns.Cast<DataGridColumn>().First(p => p.PropertyName == Rel.RelationName).PropertyColumn;

            int dataIndex = grid.Rows.IndexToDataSourceIndex(cellContext.Position.Row);

            //Check if the row is not outside the valid range (for example to handle the new row)
            if (dataIndex >= grid.DataSource.Count)

            DataView dv = grid.DataSource.GetItemValue(dataIndex, prop) as DataView;
            if (dv == null)

            JWForm form = new JWForm();
            form.View = dv;

Isn't it simple to solve our problem in Editor class?