Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1908-V100-KryptonDataGridViewDateTimePickerCell-updates #1989

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ namespace Krypton.Toolkit
public class KryptonDataGridViewDateTimePickerCell : DataGridViewTextBoxCell
{
#region Static Fields
[ThreadStatic]
private static readonly DateTimeConverter _dtc = new DateTimeConverter();
private static readonly Type _defaultEditType = typeof(KryptonDataGridViewDateTimePickerEditingControl);
private static readonly Type _defaultValueType = typeof(DateTime);
private static readonly Size _sizeLarge = new Size(10000, 10000);
#endregion

#region Instance Fields
Expand Down Expand Up @@ -574,7 +572,6 @@ protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle
object? formattedValue, string? errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
if (DataGridView is not null
&& DataGridView.Rows.SharedRow(rowIndex).Index != -1
&& KryptonOwningColumn?.CellIndicatorImage is Image image)
{
int pos;
Expand Down Expand Up @@ -617,7 +614,8 @@ protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle
{
graphics.DrawImage(image, new Point(pos, textArea.Top));

if (formattedValue is string str
if (DataGridView.Rows.SharedRow(rowIndex).Index != -1
&& formattedValue is string str
&& str.Length > 0
&& DateTime.TryParse(str, out DateTime dt))
{
Expand All @@ -643,14 +641,10 @@ protected override Rectangle GetErrorIconBounds(Graphics graphics, DataGridViewC
const int ButtonsWidth = 16;

Rectangle errorIconBounds = base.GetErrorIconBounds(graphics, cellStyle, rowIndex);
if (DataGridView!.RightToLeft == RightToLeft.Yes)
{
errorIconBounds.X = errorIconBounds.Left + ButtonsWidth;
}
else
{
errorIconBounds.X = errorIconBounds.Left - ButtonsWidth;
}

errorIconBounds.X = DataGridView!.RightToLeft == RightToLeft.Yes
? errorIconBounds.Left + ButtonsWidth
: errorIconBounds.Left - ButtonsWidth;

return errorIconBounds;
}
Expand Down Expand Up @@ -701,7 +695,6 @@ private bool OwnsEditingDateTimePicker(int rowIndex) =>
rowIndex != -1 && DataGridView is { EditingControl: KryptonDataGridViewDateTimePickerEditingControl control }
&& (rowIndex == ((IDataGridViewEditingControl)control).EditingControlRowIndex);

private static bool PartPainted(DataGridViewPaintParts paintParts, DataGridViewPaintParts paintPart) => (paintParts & paintPart) != 0;
#endregion

#region Internal
Expand Down