1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
private void COMBO_Securities_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index != -1)
{
if (COMBO_Securities.Items[e.Index] is Security)
{
Security l_oSecurity = (Security)COMBO_Securities.Items[e.Index];
StringFormat format = new StringFormat();
SolidBrush brushFond, brushTexte;
brushFond = new SolidBrush(e.BackColor);
brushTexte = new SolidBrush(e.ForeColor);
e.Graphics.FillRectangle(brushFond, e.Bounds);
// rectangle de sélection si sélection
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e.DrawFocusRectangle();
if ((COMBO_Securities.Text.Trim().Length >= 3) && ((char.IsLetter(COMBO_Securities.Text.Trim(), 0) == true) && (char.IsLetter(COMBO_Securities.Text.Trim(), 1) == true) && (char.IsDigit(COMBO_Securities.Text.Trim(), 2) == true)))
{
format.Alignment = StringAlignment.Near;
RectangleF bounds = e.Bounds;
bounds.X = 0;
e.Graphics.DrawString(l_oSecurity.IsinCode.PadRight(15),
e.Font,
brushTexte,
bounds,
format
);
bounds.X = 100;
e.Graphics.DrawString(l_oSecurity.LongName.PadRight(50),
e.Font,
brushTexte,
bounds,
format
);
bounds.X = 380;
e.Graphics.DrawString("(" + l_oSecurity.CutoffTime + " " + l_oSecurity.FrequencyCode + ")",
e.Font,
brushTexte,
bounds,
format
);
}
else
{
format.Alignment = StringAlignment.Near;
RectangleF bounds = e.Bounds;
bounds.X = 0;
e.Graphics.DrawString(l_oSecurity.LongName.PadRight(50),
e.Font,
brushTexte,
bounds,
format
);
bounds.X = 300;
e.Graphics.DrawString(l_oSecurity.IsinCode.PadRight(15), //+ "(" + l_oSecurity.CutoffTime.PadRight(6) + " " + l_oSecurity.FrequencyCode + ")",
e.Font,
brushTexte,
bounds,
format
);
bounds.X = 380;
e.Graphics.DrawString("(" + l_oSecurity.CutoffTime + " " + l_oSecurity.FrequencyCode + ")",
e.Font,
brushTexte,
bounds,
format
);
}
}
}
} |
Partager