Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
278
How can I programatically select the cell bellow the one I have just clicked?
posted
Hello. I am using an UltraGrid and I need a little bit different type of selection. When I click a cell I want to also select the cell bellow it. It was very straight forward to do this when handling the BeforeCellActivate event. Now I need to do the same thing when handling the (Before/After)SelectChange. The problem I am facing, when handling any of the SelectChange events, is that I can't modify the ultragrid1:Selected collections. At least I think so, because the exception arises only when I try to add the cell in the collection. Is this is restricted? Should I do that when handling another event? Is there another way to solve my problem? And related to this, but not so important for the moment: can I draw the focus (dotted) rectangle around both the selected cells? How can I do that? I know how to stop the Grid from drawing the rectangle (BeforeDrawFocus), but I am not sure that drawing a rectangle extending out the current cell is alright ... Is it? I am waiting for your answers. Thanks.
Parents
No Data
Reply
  • 37774
    posted

    I think that your best bet is to use the AfterSelectChange event.  What you could do is keep track of what was originally selected in the BeforeSeletChange event, then compare this to what is selected in the AfterSelectChange in order to determine which cells should be selected.  You will also likely need to keep a flag indicating that you're processing the SelectChange events so that you don't try to perform this logic recursively.

    As for the issue with the focus rect, you would have to draw it yourself using a draw filter, since it is not bound by the clip rect of the cell, but rather of the grid itself.

    -Matt

Children