Jump to content


Photo

How to use the InsertRow


  • Please log in to reply
5 replies to this topic

#1 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 02 July 2011 - 10:47 PM

Hi,

I was wondering how to use the InsertRow correctly.

The functionality I would like is:

  • Be able to enter new rows and append the entered values at the end of the grid when the Enter key is pressed.

    Escape should end editing and clear the InputRow without adding a new row.

    Default the InsertRow only adds to the grid when I click the grid to end editing.
  • Be able to edit an existing row by double clicking it.

    The original values have to be replaced by new ones if I press Enter.

    Escape should just clear the InsertRow.

Question: How to code above?

Wim van der Vegt
G.W. van der Vegt

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2011 - 01:19 AM

Hi Wim,

1) In latest release when you press Enter while you are in edit mode, inside Insert Row, new row will be added. Do you maybe think that Enter should add new row, even if Grid is not in edit mode?

Escape exits from edit mode, and you may move with arrow keys between cells.

To add Escape functionality you need do next:

In NxColumn.cs

[Browsable(false)]
        public Object InsertValue
        {
            get
            {
                return fInsertValue;
            }
            set
            {
                fInsertValue = value;
                Refresh(ColumnArea.Insert); // <---- add
            }
        }

In NextGrid.cs add:

void InplaceEdit_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Return:
                    ApplyEditing();
                    if (InsertRowSelected) AddInsertRow();
                    EndEditing();
                    break;
                case Keys.Escape:
                    EndEditing();
                    break;
                case Keys.Tab:
                    ApplyEditing();
                    EndEditing();
                    MoveByColumn(true, ModifierKeys);
                    break;
            }
            OnKeyDown(e); // <---- add
        }

Then use KeyDown event of NextGrid:

private void nextGrid1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                for (int i = 0; i < nextGrid1.Columns.Count; i++)
                {
                    nextGrid1.Columns[i].InsertValue = string.Empty;
                }
                nextGrid1.EndEditing();
            }
        }

2) Maybe SecondClickEditing property may help you?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 03 July 2011 - 01:44 PM

Hi Boki

I'll look into the code changes.

SecondClickEdit only seems works for the grid itself and only on cell level.

What I try to do is use the InsertRow as edit area when full row select is enabled. Ideally double or second clicking a row would copy the rows values into the InsertRow for editing. After editing the Selected Row should be replaced instead of adding a new one. The InsertRow should keep track of if it's editing a row or creating a new one. For this I could live with having to call a (Do)EditRow method on RowLevel.

I think this would be a nice addition in functionality.

Wim van der Vegt
G.W. van der Vegt

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2011 - 07:21 PM

Hi Wim,

Please forgive me if I didn't understand it correctly ;)

You need a method and property which will:
- Move content of double-clicked row into a InsertRow.

Am I correct?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 03 July 2011 - 09:54 PM

Hi Boki

Please forgive me if I didn't understand it correctly ;)

You need a method and property which will:
- Move content of double-clicked row into a InsertRow.

Am I correct?


I would like to use the InsertRow to edit rows (not only for adding new ones). I just do not like inplace edit together with full row select.

So i need a method to start editing a row and the InsertRow code should be smart enough to replace the row being edited when done instead of adding it to the end of the grid.

Wim van der Vegt
G.W. van der Vegt

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 04 July 2011 - 12:11 AM

Oh, I see now.

Maybe I can add a InsertRowIndex . If <> -1 in this case, row will be replaced.

I hope that this is fine solution.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users