in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Add new row

Last post 11/23/2008 7:36 PM by Brendon Muck. 5 replies.
Page 1 of 1 (6 items)
Sort Posts:
Previous Next
  • 11/19/2008 8:08 PM

    Add new row

    Hi,

    I am facing some problems with adding new row.

    I set column A with read-only and editable=false, at the other hand, when I want to add row, I can't type in column A.

    So what is the best condition or event should I use at here then I can type in column A on the new row?

  • 11/20/2008 11:42 AM In reply to

    Re: Add new row

    What is your final goal? Users can't type in Column A UNLESS it's a brand new row? If this is the case, you may want to handle the ShowingEditor event in your GridView and test the current RowHandle to determine if you need to cancel the editor display (and thus make the cell read-only).

    http://www.logisticdynamics.com
  • 11/20/2008 8:17 PM In reply to

    Re: Add new row

    Hi, thanks..

    Yes, you are right.. UNLESS that is a new row so user can type in.

    How I code in that event to recognise that is a new row?

  • 11/21/2008 11:58 AM In reply to

    Re: Add new row

    Any new Row that hasn't been saved to the underlying datasource should have a RowHandle less than zero. Knowing that, try this:

     

            private void gvMain_ShowingEditor(object sender, CancelEventArgs e)

            {

                if (gvMain.FocusedRowHandle < 0 && gvMain.FocusedColumn == this.COLUMN_A)

                {

                    //The user is attempting to edit Column A in a NEW ROW

                    e.Cancel = false;

                }

                else if (gvMain.FocusedRowHandle >= 0 && gvMain.FocusedColumn == this.COLUMN_A)

                {

                    //The user is attempting to edit Column A in an EXISTING ROW

                    e.Cancel = true;

                }           

            }  

     

    This approach assumes that your entire grid (that is, all columns) is set to Editable.

     

    http://www.logisticdynamics.com
  • 11/21/2008 11:11 PM In reply to

    Re: Add new row

    Hi.. thanks for the reply, I will try it soon...

    thanks a lot..

    Here, I also want to ask how to put an icon/ specific image based on condition?

    Thanks..

  • 11/23/2008 7:36 PM In reply to

    Re: Add new row

    Try searching the knowledge base. This topic is raised very frequently.

    http://www.devexpress.com/kb=A900

    http://www.logisticdynamics.com
Page 1 of 1 (6 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED