Hello,
I am trying to build a grid similar to those you can find in parental control application, i.e. with hours as columns, week days as rows, each cell is a boolean indicating if the object is active at this hour on this day. I hope this makes sense.
The thing is I don't want to show checkboxes but plain cell with colours (e.g. green means activated, red means deactivated). I have tried to set up this using events (InitializeRow and CellChange), based on the Text property or even a DrawFilter. It works very well for the background colour, but I didn't find anything to hide the checkbox. I then tried to use a CreationFilter: it worked well to initialize my cell with the correct background color and without the checkbox, but then the CellChange event is not fired when I click on the cell (which is, I suppose, because there is no more checkbox in the cell).
My question is: is it possible to make what I am trying to do? If yes, how?
Thanks in advance,
Damien
EDIT: Here is a screenshot of Vista parental control to illustrate what I try to achieve: http://img.clubic.com/photo/00479310.jpg
Hi Damien,
Here's a much easier way:
1) Place an UltraCheckEditor control on the form with your grid.
a) Set the Style property to Custom.
b) Set the Appearance.BackColor to Red.
c) Set the CheckedAppearance.BackColor to Green.
d) clear the Text property
2) Now set the grid column's EditorContorl property to the UltraCheckEditor control. You can use the same control for as many columns as you need.
That's it. When you click the cell in the grid it will turn red (unchecked) or green (checked).
Thanks Mike!
It is indeed easier and it works as expected!
I have now another issue related to this grid but not directly to this issue. I don't know if I should open up a new thread for it.
I want my user to be able to activate several cells at a time when dragging the mouse. I have been able to do that by:
Yet, when the user clicks several times on the same cell, the value changes only once, as afterwards the cell is already active and does not raise the AfterCellActivate event. Is there a solution for this?
For future reference, it's probably best to start a new thread for a new, unrelated question. But it's no big deal.
What you want here is to determine when the user clicks the cell, not when it is activated. So I would recommend using the MouseUp event. The tricky part is determining which cell, if any (since this event will be triggered by clicking anywhere in the grid), was clicked. So you do that using UIElements.
HOWTO:UltraWinGrid Mouse Position and Cell Identification
I'm not sure. This is very non-standard functionality. Maybe you could use the MouseMove event and trap for when the mouse button is down and then determine what cell the mouse is currently over using UIElements and toggle the value of the cell. The problem with this is that you would have to store the last cell you toggled so that it does not toggle more than once while the mouse moves within the cell.
Another option might be to set it up so you can drag the selection. You would have to set SelectTypeCell to ExtendedAutoDrag. Then use the SelectChange event to check/uncheck the cell in code.
Hi Mike,
Thanks for your answer. I am starting to believe that my issue is far more complicated that i first thought it was!
When I say select, I trully mean select. Everything lies in this dragging feature I am trying to set up. Did you find out what I am trying to do with the sample I provided?
I'll try to explain it differently. I want my user to be able to change the value of several cells by for example clicking on monday 7am and dragging the mouse up to monday 8pm. I did not find a way to check those cells when dragging, but I found out how to activate them. That's why I set up my grid the way I did (CellClickAction = CellSelect and AfterCellActivate event).
The ideal though would be to be able to check several cells when dragging the mouse over them: is it possible?
Okay, I think the confusion here is coming from the meaning of the word Select. I thought you were talking about using the selection functionality to select cells in the grid. But I think you when you say select here, you mean check.
When you click on a checkbox cell in the grid, the value automatically toggles. The reason it's not working in this example is because you are setting CellClickAction on the grid to CellSelect, so the cell is getting selected rather than toggling the value. Turn this off and it works okay - except that your AfterCellActivate event is now fighting this. You have to look at the ActiveCell.Text inside AfterCellActivate instead of Value.
Here is a sample application of what I am doing. So far, I am able to "activate" several cells by dragging the mouse, but if you click several times on the same cell, the status does not change. I hope this will help you understand what I mean.
I don't understand what you mean.