If I have 2/3/4 etc rows in my UltraGrid, I've got an issue. I'm trying to allow edit of 2 columns in the active row when the date column value is changed.
The 2 cells are only editable once the top row in the grid has had a date value entered.
However, I want it to activate for the row that the date was entered on, even if the top row hasn't got a date value.
I've also tried just updating the bottom row, clicking a different control, and seeing if it works then, but it still doesn't.
Am I doing something wrong? I've tried both of the activation lines using the e.Cell.Row.Cells method, and the row.Cells method.
Try If e.Cell.Column.Key = "PaymentDate" Then e.Cell.Row.Cells("Customer_Paid").Activation = Activation.AllowEdit e.Cell.Row.Cells("Customer_Paid").Value = True row.Cells("suppInvoiceNum").Activation = Activation.AllowEdit End If Catch ex As Exception errorLog(ex) End Try
Hi David,
I'm having a very hard time understanding what you are trying to achieve. Even the code snippet you have here isn't really very useful, since I don't know what event this code is in.
Maybe you could post a screen shot or a sample application with more details about exactly what you are trying to do.
Hi Mike,
Apologies for the confusion.
I'm trying to attach an image, but it wants a URL? Where can I insert an image to clarify what I mean?
When replying, go to the Options tab and then just attach the image as a file.
Okay, so, see the below image;
You'll see there are 2 rows in this grid. What I'm trying to do, is enter a payment date onto the second row. When I select a date, the Customer Paid checkbox is supposed to set to 'True', and the Supplier Invoice Number column should become activated, allowing me type into the cell on the bottom row.
The code I have is successfully setting the checkbox to True, but then I cannot set it back to False, and cannot type into the invoice number cell - So neither are having the activation set to AllowEdit.
However, when I enter a date for the top row, it will then allow activation for both columns on both rows. Further testing also shows that when entering a date on the top row, both rows can be activated, even if the bottom has no date, which isn't what I'm aiming for.
David Hooley said:You'll see there are 2 rows in this grid. What I'm trying to do, is enter a payment date onto the second row. When I select a date, the Customer Paid checkbox is supposed to set to 'True', and the Supplier Invoice Number column should become activated, allowing me type into the cell on the bottom row.
Okay... just to clarify, you said you are typing into the second row and then you mentioned the bottom row. These are the same row, right?
I still don't know what event your code is in. So it's hard to say what's going on here. The one thing I do suggest you be careful of is that you should not set the Activation of a cell that is already in edit mode - or about to enter edit mode. Setting this property has to happen BEFORE the cell is active. So maybe that's part of the issue. This code also does not appear to be checking if the Payment date has been set or not. So presumably it gets called after you set it - maybe in the CellChange event?
This code is setting the Activation to allow editing, but that's the default. So in what event are you setting it to prevent editing in the first place?
Sorry, yes, the bottom row and the second row are the same.
This code is in the CellChange event, so is getting called whenever the date value changes. How would I set edit mode before activating the cell, and do you think that this is therefore the issue? Don't forget, if I only change the date value on the top row, the 2 cells become active for both rows, regardless of if the other one has been given a date value or not.
CellClickAction and Activation/CellActivation are two different things.
Setting CellClickAction to CellSelect, for example, does NOT prevent the user from editing the cell. They can still select that cell and press F2 to enter edit mode. So you don't want to use that property by itself to prevent editing.
I'm also not sure how that could have caused the behavior you described earlier. You seemed to be saying that cells were editable that should not be. CellClickAction would have the opposite effect, making it so that clicking on a cell would NOT enter edit mode. So I really don't get what's going on there. Seems like there is quite a bit to this that you are leaving out and so it's hard for me to keep up.
Anyway... to answer your immediate question, you can set the CellClickAction property on the Override or the Column. So you can set it on each column if you want. But like I said, this property alone will not prevent editing.
Not to worry, the issue appeared to be that in the form load event I was calling ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect, so I've added in ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.Edit into the code above and this appears to have fixed the issue - Unless there is a way to set the CellClickAction for just the columns I want to edit?
Okay, if this is in CellChange, then the code you have here looks fine to me. I don't see anything wrong with it. And there's no way I can imagine that this code would affect a different row than the one you are currently changing. So there must be something else in your code that is causing the issue.
You didn't answer my question about where/how you are disabling the editing in the first place.
Maybe you could try to reproduce this behavior in a small sample project and post it here and I can take a look.