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 Mike,
I understand your point, but by doing this I do not allow the user to "activate" (ie change the value) of several cells by clicking on the mouse and dragging it over the cells, which the main reason why I am using this instead of the default behaviour.
Hi Damien,
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
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?
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).