Welcome to the Xceed Community | Help
Community Search  

getting the row number in a button column

Page 1 of 2 (17 items)   1 2 Next >
Sort Posts: Previous Next
  •  09-07-2008, 5:14 AM Post no. 14972

    getting the row number in a button column

    I have a button column in my grid

    When user is pressing the button I would like to get the row number

    How can I get it?

  •  09-08-2008, 8:38 AM Post no. 14989 in reply to 14972

    Re: getting the row number in a button column

    You can handle the button's Click event and in there retrieve a reference to the grid's CurrentItem (the button that was clicked will be located in the current item). From there, you can access the grid's Items collection and get the index of the current item using IndexOf.


    Technical Writer - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  09-09-2008, 5:15 AM Post no. 15059 in reply to 14989

    Re: getting the row number in a button column

    Thanks,

    But the problem is the current item is null in the button click event.

  •  09-10-2008, 8:51 AM Post no. 15120 in reply to 14989

    Re: getting the row number in a button column

    what do you mean  by retrieve a reference to the grid's current Item How can I do it?.

     

  •  09-10-2008, 9:09 AM Post no. 15126 in reply to 15120

    Re: getting the row number in a button column

    myGrid.CurrentItem property
    Technical Writer - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  09-10-2008, 9:21 AM Post no. 15127 in reply to 15126

    Re: getting the row number in a button column

    the problem as I mentioned before is that the current item is null in the button click event 
  •  10-03-2008, 10:26 AM Post no. 15879 in reply to 15127

    Re: getting the row number in a button column

    I also have the same issue my column is below but when handling the Click event the CurrentItem is null as well as SelectedItem. The Items collection CurrentItem is not null but just the first row in the grid.
  •  10-06-2008, 10:01 AM Post no. 15908 in reply to 15879

    Re: getting the row number in a button column

    As long as the grid has a current item before the button is clicked, the CurrentItem property should not be null.
    Technical Writer - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  10-06-2008, 10:24 AM Post no. 15910 in reply to 15908

    Re: getting the row number in a button column

    It doesn't so how does clicking the button in the row make the CurrentItem not null?
  •  10-06-2008, 10:31 AM Post no. 15911 in reply to 15910

    Re: getting the row number in a button column

    If the grid does not have a current item when the button is clicked, then the CurrentItem property will be null. This is normal behavior. If you want to have a current item, then you will need to set the CurrentItem property or click on an item in the grid to make it current.
    Technical Writer - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  10-06-2008, 10:53 AM Post no. 15914 in reply to 15911

    Re: getting the row number in a button column

    Surely that goes against the point of a button in a column. When you click a button on row 5 you expect the CurrentItem to be set to row 5. Is there anyway to enforce that behaviour?

     

    Thanks

  •  10-06-2008, 2:56 PM Post no. 15921 in reply to 15914

    Re: getting the row number in a button column

    Not if the focus is caught by the button first. If the focus never reaches the grid, then the current item cannot "automatically" be set. You could always set the current item yourself programatically in the button's Click event.
    Technical Writer - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  10-07-2008, 6:06 AM Post no. 15933 in reply to 15921

    Re: getting the row number in a button column

    How do I know what to set the CurrentItem to?
  •  10-07-2008, 8:46 AM Post no. 15941 in reply to 15933

    Re: getting the row number in a button column

    There are several ways to get to data item for a Row or Cell... But the simplest is to use the Row's DataContext (or Cell`s).

    myDataGridControl.CurrentItem = myRow.DataContext;

    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  10-07-2008, 10:39 AM Post no. 15945 in reply to 15941

    Re: getting the row number in a button column

    How do I find the cell or row the button is in?
Page 1 of 2 (17 items)   1 2 Next >
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.