Posted 26 August 2021, 9:25 pm EST
Hi, everyone!
I have a C1FlexGrid, and I draw a custom DateTimePicker in a column for each row.
What I want is that when scrolling, if a row is partially visible, the DateTimePicker in that row is also partially visible.
But the problem is, as you can see in the attached picture, the DateTimePicker in the top row covers the one in the second row.
I wonder if there is a way to solve that problem.
Here is the rendering code of those DateTimePickers.
I add them to myDataGrid (C1FlexGrid)'s Controls property, and set their bounds in the Paint event of the flex grid.
private void myDataGrid_Paint(object sender, PaintEventArgs e)
{
foreach (var dateTimePicker in this.dateTimePickers)
{
// Get the Tag of a DateTimePicker
TagInfo tagInfo = (TagInfo)dateTimePicker.Tag;
// Current row of the flex grid
int row = tagInfo.row;
int col = tagInfo.col;
// Bound of the cell in which I draw the DateTimePicker
Rectangle rc = this.myDataGrid.GetCellRect(row, col, false);
// Situations that undraw the DateTimePicker
if (rc.Width <= 0 || rc.Height <= 0 || !rc.IntersectsWith(this.myDataGrid.ClientRectangle))
{
dateTimePicker.Visible = false;
continue;
}
// Set the bound of a DateTimePicker
dateTimePicker.Bounds = rc;
dateTimePicker.Visible = true;
}
}
The full source code is here:
code.zip