private void transactionGrid_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { TextFormatFlags flags = TextFormatFlags.Left; using (StringFormat sf = new StringFormat()) { // Store the column text alignment, letting it default // to Left if it has not been set to Center or Right. switch (e.Header.TextAlign) { case HorizontalAlignment.Center: sf.Alignment = StringAlignment.Center; flags = TextFormatFlags.HorizontalCenter; break; case HorizontalAlignment.Right: sf.Alignment = StringAlignment.Far; flags = TextFormatFlags.Right; break; } CultureInfo culture; DateTimeStyles styles; DateTime dateResult; culture = CultureInfo.CreateSpecificCulture("fr-FR"); styles = DateTimeStyles.None; if (DateTime.TryParse(e.SubItem.Text, culture, styles, out dateResult)) { sf.Alignment = StringAlignment.Far; Brush b; b = ((e.Item.Tag as Transaction).Cleared) ? Brushes.Black : Brushes.Red; e.Graphics.DrawString(_Globals.myDateStr(dateResult), transactionGrid.Font, b, e.Bounds, sf); return; } e.DrawText(flags); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)