first Row Deleting Problem

20 posts, 0 answers
  1. Rehan
    Rehan  avatar
    9 posts
    Member since:
    Jan 2008

    Posted 14 Jun 2008 Link to this post

    i was working wd telerik Q3 2007 due to deleting Cresh problem and some others issues i jst switched to Q1 2008 SP1. bt i still found an error. as Row deleting/RowDeleted function has been replaced with RowChanging/RowChanged.we i hve only one row and i m gonna delete that row RowChanging Event Works Fine bt i could not be able to catch RowChanged Event as i want to do some work on RowChanged as well. Is any other event that could allow me not to much changes in my Code ?
  2. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 16 Jun 2008 Link to this post

    Hi Rehan ,

    I'm not sure I completely understand your scenario.

    In Q1 2008, the event system of the RadGridView has been changed. In older versions, there were a variety of events for the different operations that can be performed on the data stored in the grid. These have been replaced by one event, which is raised with different event args.

    This means that you will not have to place your code in the handler for a different event. Place all of the code you need to perform after a deletion of a row in the handler of the RowChanging event. You only need to verify that the event arguments indicate that a row has been deleted.

    If you have any further questions, please contact me.

    All the best,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Rehan
    Rehan  avatar
    9 posts
    Member since:
    Jan 2008

    Posted 17 Jun 2008 Link to this post

    dear i think you cant understand my Problem. ok let me give u the example code .

     

    Private

    Sub RadGridView1_RowsChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.RowsChanging

    ''' MsgBox("step row changing")

    If e.Action = Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove Then

    Dim cCancel As DialogResult

    cCancel = MessageBox.Show(

    "Are you sure you want to delete the selected row ?", SystemConfiguration.MessageTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question)

    If cCancel = DialogResult.Yes Then

    If Me.RadGridView1.Rows(CurrentRow).IsCurrent = False Or Me.RadGridView1.Rows(CurrentRow).Cells(ItemNumberColumn).Value.ToString() = "" Then

    Else

    UpdateITMTable.SubQtyInEachItemLine(Me.RadGridView1.Rows(CurrentRow).Cells(ItemNumberColumn).Value, Me.RadGridView1.Rows(CurrentRow).Cells(QuantityColumn).Value)

    CurrentRowDeleted =

    True

    End If

    Else

    e.Cancel = True

    End If

    End If

    End Sub


    this is wut i m doing behid the rowchanging event ... here if we have only 1 row ... row changing event will occured and i say yeah i want to delete the row and my code behind deletion do some calculations on grid rows count. if i call it here then rows will be still 1 as this event is in process.

    the calculation code only needs to call at RowChanged Event as you ppl also mention that in Q1 2008

    RowDeleting

    /RowDeleted events have been replaced by RadGridView

    RowsChanging

    /RowsChanged events.

    the only problem is that if we have only 1 row in gridview we cant be able to catch RowChanged Event.bt if we have more then one row it works f9.

  5. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 17 Jun 2008 Link to this post

    Hi Rehan ,

    Thank you for writing.

    I managed to reproduce the issue you described, and I thank you for bringing our attention to the issue. This issue will be addressed for the Q2 2008 release. For the time being, You'll be able to place your code which is meant to be executed in the handler of the CurrentRowChanged after row deletion the RowsDeleting event. 

    Let me know whether this solves the issue in your scenario.

    Your Telerik points have been updated. If you have any further questions, please let me know.

    Kind regards,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Rehan
    Rehan  avatar
    9 posts
    Member since:
    Jan 2008

    Posted 17 Jun 2008 Link to this post

    hi Kiril,
    dear i already tried to solve this issue wd CurrentRowChanged handler bt just failed it gives an error
    "This row has been removed from a table and does not have any data.  BeginEdit() will allow creation of new data in this row."


    at CurrentRowChanged event i observed it did not decrease the radGrid Row.
    i think i need to change my code for the purpose :) ...


  7. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 18 Jun 2008 Link to this post

    Hi Rehan ,

    Excuse me for taking so long to resolve this issue. The issue you reported has been added to our TODO list and will be resolved in one of the future releases. For the time being, there's another method you can use to execute logic following the deletion of a row - subscribe to the ListChanged method the datasource of the grid control.

    this.radGridView1.DataSource = customersBindingSource;  
    customersBindingSource.ListChanged += new ListChangedEventHandler(customersBindingSource_ListChanged); 

    In the handler of this event, you can place the code below, to let you know when an item has been deleted:

    void customersBindingSource_ListChanged(object sender, ListChangedEventArgs e)  
    {  
        switch (e.ListChangedType)  
        {  
            case ListChangedType.ItemDeleted:  
                //your code here  
                break;  
        }  

    I hope this helps. If you have further questions, please let me know.

    Regards,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. David
    David avatar
    4 posts
    Member since:
    Dec 2007

    Posted 15 Aug 2008 Link to this post

    Hi ,

    I have encountered the same issue which my last row deletion event never get the chance to fire.The suggested method is taggng on bindingsource whch i am not using. Any alternative ways for non-binding  datasource.

    David
  9. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 Aug 2008 Link to this post

    Hello David,

    Thank you for this question.

    I confirm that in the latest release of RadGridView the RowsChanged event isn't fired when there is only one row. This issue will be addressed in our upcoming service pack.

    To work around the issue you could process the RowChanging event instead. Consider the code below:

    void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) 
        if (e.Action == NotifyCollectionChangedAction.Remove) 
        { 
        } 


    I hope this helps you. Please let me know if you need further assistance.

    Regards,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. David
    David avatar
    4 posts
    Member since:
    Dec 2007

    Posted 15 Aug 2008 Link to this post

    Hi Jack,

    That will not help as after the last row deletion, i need to trigger a function to recalcute the figures. At row changing, the grid row count is still at 1 and only after this event than that row data is clear.

    Plus i encountered grid index=-1 error after i delete the all grid  rows and edit one column of the new row i created. Please advise.
  11. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 Aug 2008 Link to this post

    Hi David,

    Thank you for getting back to me.

    Our next service pack will be released in 10 days from now and it will address this issue. If the issue is a show stopper for you, please send me a sample project that reproduces it (you can do so in a support ticket). I will try to find a solution for you.

    Do not hesitate to write me if you have other questions.
     

    Greetings,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  12. ewart
    ewart avatar
    221 posts
    Member since:
    Jan 2007

    Posted 21 Nov 2008 Link to this post


    Jack, I've just spent an hour on this using the latest version of controls and my experience is that the _RowsChanged event still does not work properly.  Regardless of row number or how many rows are left, when removing a row it fills the NewItems[] collection with one row - it should fill the OldItems and it's not even the row I deleted!  Very frustrating.

    Can you confirm this is still an existing bug with the grid, or is this something new to report?

    Regards
      Ewart.


  13. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 21 Nov 2008 Link to this post

    Hello ewart,

    Thank you for bringing our attention to this issue.

    I understand your frustration and to my regret I have to can confirm that it still exists. I have added the issue with high priority in our TODO for the upcoming service pack. Your Telerik points have been updated.

    Don't hesitate to contact us if you have other questions.


    Greetings,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  14. Support
    Support avatar
    5 posts
    Member since:
    Feb 2007

    Posted 02 Dec 2008 Link to this post

    Hi, any news on a fix for this?  I'm suffering with the same problem.
  15. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 04 Dec 2008 Link to this post

    Hello Rehan,

    The RowsChanged event is fired after removing the row in this case. So, it is not possible to get an instance to the row, because it is already destroyed. Because of all this, the OldItems array is empty. The NewItems array contains the new row at the specified position. This behavior is by design.

    I would suggest using the RowsChanging event to get the row that is being deleted. If you need any further assistance I will be glad helping you.
     

    All the best,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  16. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jul 2008

    Posted 13 Dec 2008 Link to this post

    I am experiencing a similar situation and am very much in need of a solution.

    I'm setting the datasource of my radgridview to a datatable. When I remove the first row of the datagrid programatically from the datatable....the datasource is updated accurately...but the gridview does not update...so therefore the gridview is out of sync with the datasource.

    (I'm using RadControls for WinForms...Version 7.1.1.0)

    Is there a work around for this yet?

    Thanks,
    Ryan

  17. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 Dec 2008 Link to this post

    Hello Ryan,

    Thank you for your question.

    Yes, we did have this problem, add it has been addressed since. I tired it again with the latest version and the grid updates properly. I would recommend trying the Q3 2008 SP1 version of RadControls for WinForms. We will highly appreciate any feedback you have.

    Do not hesitate to write us if you have other questions.

    Regards,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  18. Ryan
    Ryan avatar
    25 posts
    Member since:
    Jul 2008

    Posted 22 Dec 2008 Link to this post

    I have upgraded to Q3 and now when I try to delete the first row in my grid I get this exception....

    "Exception has been thrown by the target of an invocation."

  19. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 23 Dec 2008 Link to this post

    Hello Ryan,

    Thank you for getting back to us.

    I need more information to locate the source for this issue. Could you, please open a support ticket and send me your application that reproduces the issue? This will help me find a proper solution for you.

    Thank you in advance for your cooperation.
     

    Sincerely yours,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  20. Jorge Mendoza Martinez
    Jorge Mendoza Martinez avatar
    1 posts
    Member since:
    Apr 2010

    Posted 09 Jun 2010 Link to this post

    I have this problem to I am using the version 2010 Sp1.
    I try to Delete the first row and after delete the row present a error say: Index 0 is either negative or above rows count., 

     Private Sub rgvWidth_RowsChanging(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles rgvWidth.RowsChanging
            Try
                Select Case e.Action
                    Case Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove
                        If CType(e.OldItems(0), GridViewDataRowInfo).Cells("Id").Value <> 0 Then
                           ' Delete the row in the data base and reload all the Data
                            RemoveMatedSetWidth(CType(e.OldItems(0), GridViewDataRowInfo).Cells("Id").Value)
                        End If
                End Select
            Catch ex As Exception
                rgvWidth.CancelEdit()
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Samtec Product Data Base")
                LoadMatedSetWidth()
            End Try
        End Sub


  21. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 Jun 2010 Link to this post

    Hi Jorge Mendoza Martinez,

    Thank you for contacting us. I tested this case, however I was not able to reproduce the issue. Please send me your application and I will try to locate the issue and find a proper solution.  Thank you in advance.

    I am looking forward to your reply.

    Best wishes,
    Jack
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WinForms is Visual Studio 2017 Ready