Conditional formatting in a DataGrid using .Net Compact Framework 3.5?

I'm having the same trouble atm, here's my soloution so far.

I'm having the same trouble atm, here's my soloution so far: public class DataGridExtendedTextBoxColumn : DataGridTextBoxColumn { // I use the Form to store Brushes and the Font, feel free to handle it differently. Form1 parent; public DataGridExtendedTextBoxColumn(Form1 parent) { this. Parent = parent; } // You'll need to override the paint method // The easy way: only change fore-/backBrush protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) { base.

Paint(g, bounds, source, rowNum, parent. RedBrush, parent. FontBrush, alignToRight); } } The hard way: draw it yourself protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) { // Background g.

FillRectangle(parent. RedBrush, bounds); // Get and format the String StringFormat sf = new StringFormat(); DataRowView dataRowView = (DataRowView)source. ListrowNum; DataRow row = dataRowView.

Row; Object value = rowthis. MappingName; String str; if (value. Equals(System.DBNull.

Value)) { str = this. NullText; } else if (this.Format. Length!

= 0) { // NOTE: Formatting is handled differently! Str = String. Format(this.

Format, value); } else { str = value.ToString(); } // Draw the String g. DrawString(str, parent. Font, parent.

FontBrush, new RectangleF(bounds. X, bounds. Y, bounds.

Width, bounds. Height)); //base. Paint(g, bounds, source, rowNum, parent.

RedBrush, parent. FontBrush, alignToRight); } The last approach gives you complete controll. Note that the format string would look something like this: this.

DataGridTextBoxColumn1. Format = "{0:0000}"; Instead of this. DataGridTextBoxColumn1.

Format = "0000"; To add the Coloums: // The "this" is due to the new constructor this. DataGridTextBoxColumn1 = new DataGridExtendedTextBoxColumn(this); this. DataGridTableStyle1.

GridColumnStyles. Add(this. DataGridTextBoxColumn1); The only way to change the height of the rows seems to change DataGrid.

PreferedRowHeight but this set the height for all rows. Depending on your needs it might be a good idea to derive a new class for every column. This is still work in progress for me, so if you've got any tipps let me know, please.

Good luck with that ;D.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions