Is there guidelines for proper use of DataGrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Is there guidelines for proper use of DataGrid

  1. #1
    Thomas Eyde Guest

    Is there guidelines for proper use of DataGrid

    I struggle with the datagrid, it seems like it is very fragile on changing
    data in the datasource...

    Is there some guidelines on how to use the datagrid out there somewhere?

    What I want to accomplish is this:
    - Show a list of objects. Each list entry will show a subset of object's
    properties.
    - Select a list item. This will populate edit fields another place on form.
    - Edit fields, commit changes to database.
    - Update datagrid, preferely keeping the selected item.

    variations (1):
    - Create a new object, this will only clear edit fields in the first place
    - Edit fields, commit changes to database. This will add a new row.
    - Update datagrid, preferely with the new item selected.

    variations (2):
    - Select a list item
    - Delete it. This will remove a row in database.
    - Update datagrid, preferely with closest item to the deleted one being
    selected

    Trial 1 - Bind a data table:
    - Bind a datatable to grid.
    - Update database.
    - Use adapter.Fill to refresh table.

    This works on Add and Update, but not delete. For some reason adapter.Fill
    will not remove nonexisting item.

    Trial 2 - Bind a data table, clear table
    - Same as one, but do a table.Clear before adapter.Fill when deleting.

    DataGrid throws an array out of bounds exception whenever I click it after a
    deletion.

    Trial 3 - Bind a data table, use table.Delete (or was it row.Delete?)
    - Bind a datatable to grid.
    - Use adapter.Fill when adding or updating
    - Use table.Delete when deleting

    DataGrid seem to accept this approach, but now I have two different ways to
    update the database:
    - When I add or update I notify table of changes. Table is passive.
    - When I delete, I first have to delete row from table, then use the table
    to notify database. Now table is active.

    Trial 4 - Bind a list (yet to try):
    - The idea is to bind an ArrayList to grid.

    I haven't tried this path yet. Seem to be too much of manual syncronations:
    - Commit edits to database, refill list object with data from database
    - Commit deletion to database, if successfull then remove object from list
    - Notify datagrid that data has changed.

    ..thomas



  2. #2
    MMFAN Guest

    Re: Is there guidelines for proper use of DataGrid


    I struggle just getting out of bed in the morning, can someone give me a wakeup
    call every day around noon?
    "Thomas Eyde" <thomas.eyde@online.no> wrote:
    >I struggle with the datagrid, it seems like it is very fragile on changing
    >data in the datasource...
    >
    >Is there some guidelines on how to use the datagrid out there somewhere?
    >
    >What I want to accomplish is this:
    >- Show a list of objects. Each list entry will show a subset of object's
    >properties.
    >- Select a list item. This will populate edit fields another place on form.
    >- Edit fields, commit changes to database.
    >- Update datagrid, preferely keeping the selected item.
    >
    >variations (1):
    >- Create a new object, this will only clear edit fields in the first place
    >- Edit fields, commit changes to database. This will add a new row.
    >- Update datagrid, preferely with the new item selected.
    >
    >variations (2):
    >- Select a list item
    >- Delete it. This will remove a row in database.
    >- Update datagrid, preferely with closest item to the deleted one being
    >selected
    >
    >Trial 1 - Bind a data table:
    >- Bind a datatable to grid.
    >- Update database.
    >- Use adapter.Fill to refresh table.
    >
    >This works on Add and Update, but not delete. For some reason adapter.Fill
    >will not remove nonexisting item.
    >
    >Trial 2 - Bind a data table, clear table
    >- Same as one, but do a table.Clear before adapter.Fill when deleting.
    >
    >DataGrid throws an array out of bounds exception whenever I click it after

    a
    >deletion.
    >
    >Trial 3 - Bind a data table, use table.Delete (or was it row.Delete?)
    >- Bind a datatable to grid.
    >- Use adapter.Fill when adding or updating
    >- Use table.Delete when deleting
    >
    >DataGrid seem to accept this approach, but now I have two different ways

    to
    >update the database:
    >- When I add or update I notify table of changes. Table is passive.
    >- When I delete, I first have to delete row from table, then use the table
    >to notify database. Now table is active.
    >
    >Trial 4 - Bind a list (yet to try):
    >- The idea is to bind an ArrayList to grid.
    >
    >I haven't tried this path yet. Seem to be too much of manual syncronations:
    >- Commit edits to database, refill list object with data from database
    >- Commit deletion to database, if successfull then remove object from list
    >- Notify datagrid that data has changed.
    >
    >..thomas
    >
    >



  3. #3
    Jay Glynn Guest

    Re: Is there guidelines for proper use of DataGrid

    I'm doing a lot of this now with binding. What you need to look at is
    IEditableObject, IBindingList and possibly ITypedList. Implementing these
    interfaces looks like a lot of work, but it really isn't, and all of the
    sync stuff is handled. I'm able to bind complex objects (objects that
    contain collections of other objects etc) and have the data show on the form
    with very little gui coding. Datasets and such never make it to the gui, I
    return nothing but objects and collections from the middle layer. Once you
    get your head around it is very powerful stuff.

    "Thomas Eyde" <thomas.eyde@online.no> wrote in message
    news:3d479778@10.1.10.29...
    > I struggle with the datagrid, it seems like it is very fragile on changing
    > data in the datasource...
    >
    > Is there some guidelines on how to use the datagrid out there somewhere?
    >
    > What I want to accomplish is this:
    > - Show a list of objects. Each list entry will show a subset of object's
    > properties.
    > - Select a list item. This will populate edit fields another place on

    form.
    > - Edit fields, commit changes to database.
    > - Update datagrid, preferely keeping the selected item.
    >
    > variations (1):
    > - Create a new object, this will only clear edit fields in the first place
    > - Edit fields, commit changes to database. This will add a new row.
    > - Update datagrid, preferely with the new item selected.
    >
    > variations (2):
    > - Select a list item
    > - Delete it. This will remove a row in database.
    > - Update datagrid, preferely with closest item to the deleted one being
    > selected
    >
    > Trial 1 - Bind a data table:
    > - Bind a datatable to grid.
    > - Update database.
    > - Use adapter.Fill to refresh table.
    >
    > This works on Add and Update, but not delete. For some reason adapter.Fill
    > will not remove nonexisting item.
    >
    > Trial 2 - Bind a data table, clear table
    > - Same as one, but do a table.Clear before adapter.Fill when deleting.
    >
    > DataGrid throws an array out of bounds exception whenever I click it after

    a
    > deletion.
    >
    > Trial 3 - Bind a data table, use table.Delete (or was it row.Delete?)
    > - Bind a datatable to grid.
    > - Use adapter.Fill when adding or updating
    > - Use table.Delete when deleting
    >
    > DataGrid seem to accept this approach, but now I have two different ways

    to
    > update the database:
    > - When I add or update I notify table of changes. Table is passive.
    > - When I delete, I first have to delete row from table, then use the table
    > to notify database. Now table is active.
    >
    > Trial 4 - Bind a list (yet to try):
    > - The idea is to bind an ArrayList to grid.
    >
    > I haven't tried this path yet. Seem to be too much of manual

    syncronations:
    > - Commit edits to database, refill list object with data from database
    > - Commit deletion to database, if successfull then remove object from list
    > - Notify datagrid that data has changed.
    >
    > .thomas
    >
    >




  4. #4
    Thomas Eyde Guest

    Re: Is there guidelines for proper use of DataGrid

    I have seen those interfaces mentioned in the documents, but seen no
    examples on how to do it. Do you know of any articles, or perhaps some code?

    Thanks.
    ..thomas

    "Jay Glynn" <jlsglynn@hotmail.com> wrote in message
    news:3d487ba0$1@10.1.10.29...
    > I'm doing a lot of this now with binding. What you need to look at is
    > IEditableObject, IBindingList and possibly ITypedList. Implementing these
    > interfaces looks like a lot of work, but it really isn't, and all of the
    > sync stuff is handled. I'm able to bind complex objects (objects that
    > contain collections of other objects etc) and have the data show on the

    form
    > with very little gui coding. Datasets and such never make it to the gui, I
    > return nothing but objects and collections from the middle layer. Once you
    > get your head around it is very powerful stuff.





  5. #5
    Jay Glynn Guest

    Re: Is there guidelines for proper use of DataGrid

    <shameless_plug>
    I did the data binding chapter in an upcoming book Professional Windows GUI
    Programming with C#. ISBN:1861007663. Should be out in a couple of weeks.
    </shameless_plug>
    I go past binding datasets and such in the chapter, I show how to implement
    all of these interfaces.

    Jay

    "Thomas Eyde" <thomas.eyde@online.no> wrote in message
    news:3d48e57a@10.1.10.29...
    > I have seen those interfaces mentioned in the documents, but seen no
    > examples on how to do it. Do you know of any articles, or perhaps some

    code?
    >
    > Thanks.
    > .thomas
    >
    > "Jay Glynn" <jlsglynn@hotmail.com> wrote in message
    > news:3d487ba0$1@10.1.10.29...
    > > I'm doing a lot of this now with binding. What you need to look at is
    > > IEditableObject, IBindingList and possibly ITypedList. Implementing

    these
    > > interfaces looks like a lot of work, but it really isn't, and all of the
    > > sync stuff is handled. I'm able to bind complex objects (objects that
    > > contain collections of other objects etc) and have the data show on the

    > form
    > > with very little gui coding. Datasets and such never make it to the gui,

    I
    > > return nothing but objects and collections from the middle layer. Once

    you
    > > get your head around it is very powerful stuff.

    >
    >
    >




  6. #6
    Jay Glynn Guest

    Re: Is there guidelines for proper use of DataGrid


    "Thomas Eyde" <thomas.eyde@online.no> wrote:
    >I have seen those interfaces mentioned in the documents, but seen no
    >examples on how to do it. Do you know of any articles, or perhaps some code?
    >
    >Thanks.
    >..thomas



    Send me an email address and I'll send you a couple of examples.


  7. #7
    Tim Hitchings \(Infragistics\) Guest

    Re: Is there guidelines for proper use of DataGrid

    Using the DataGrid:
    http://www.syncfusion.com/FAQ/WinForms/default.asp#43

    Using the Infragistics UltraWinGrid:
    http://www.infragistics.com/support/...?article=02011
    http://www.infragistics.com/support/...?article=01925
    http://www.infragistics.com/support/...?article=01696
    http://www.infragistics.com/support/...?article=01684
    http://www.infragistics.com/support/...?article=01664
    http://www.infragistics.com/support/...?article=01662
    http://www.infragistics.com/support/...?article=01660
    http://www.infragistics.com/support/...?article=01656





    "Thomas Eyde" <thomas.eyde@online.no> wrote in message
    news:3d48e57a@10.1.10.29...
    > I have seen those interfaces mentioned in the documents, but seen no
    > examples on how to do it. Do you know of any articles, or perhaps some

    code?
    >
    > Thanks.
    > .thomas
    >
    > "Jay Glynn" <jlsglynn@hotmail.com> wrote in message
    > news:3d487ba0$1@10.1.10.29...
    > > I'm doing a lot of this now with binding. What you need to look at is
    > > IEditableObject, IBindingList and possibly ITypedList. Implementing

    these
    > > interfaces looks like a lot of work, but it really isn't, and all of the
    > > sync stuff is handled. I'm able to bind complex objects (objects that
    > > contain collections of other objects etc) and have the data show on the

    > form
    > > with very little gui coding. Datasets and such never make it to the gui,

    I
    > > return nothing but objects and collections from the middle layer. Once

    you
    > > get your head around it is very powerful stuff.

    >
    >
    >




  8. #8
    Jay Glynn Guest

    Re: Is there guidelines for proper use of DataGrid


    "Tim Hitchings \(Infragistics\)" <productmanager@infragistics.com> wrote:
    >Using the DataGrid:
    >http://www.syncfusion.com/FAQ/WinForms/default.asp#43
    >
    >Using the Infragistics UltraWinGrid:
    >http://www.infragistics.com/support/...?article=02011
    >http://www.infragistics.com/support/...?article=01925
    >http://www.infragistics.com/support/...?article=01696
    >http://www.infragistics.com/support/...?article=01684
    >http://www.infragistics.com/support/...?article=01664
    >http://www.infragistics.com/support/...?article=01662
    >http://www.infragistics.com/support/...?article=01660
    >http://www.infragistics.com/support/...?article=01656
    >



    Good articles. Might I suggest that you also include C# examples ;-)....

    BTW I really like using UltraWinGrid. It has been rock solid for me so far.
    I'll probably be upgrading to the suite so I can get the source in the not
    to distant future.

  9. #9
    Tim Hitchings \(Infragistics\) Guest

    Re: Is there guidelines for proper use of DataGrid


    "Jay Glynn" <agfgdev@hotmail.com> wrote in message
    news:3d493972$1@10.1.10.29...
    >
    > Good articles. Might I suggest that you also include C# examples ;-)....


    We do when time permitts. Most KB articles are either or.

    >
    > BTW I really like using UltraWinGrid. It has been rock solid for me so

    far.
    > I'll probably be upgrading to the suite so I can get the source in the not
    > to distant future.


    Glad your happy. You would be upgrading to the Infragistics NetAdvantage
    subscription in order to get the source. You also get all new products
    released for a year. We just started the beta for UltraWinToolbars.
    Registered users of our products can sign up for the beta on the front page
    of the infragistics web site.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center