protected virtual void PaintCell(Graphics g, Rectangle cellBounds) { if (CellFunctions.MouseHitTest(_parent, cellBounds)) { OpenPopup(); } else { ClosePopup(); } Brush fontColor = new SolidBrush(this.Style.ForeColor);// CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor); //SizeF textSize = TextSize("Text", g); //_fontHeight = (int)textSize.Height; //String allText = ""; Items.SetNormalFontColor(fontColor); String text = ""; int remainedSize = cellBounds.Width; for (int i = 0; i < Items.Count; i++) { text += Items.Keys.ElementAt(i) + ":" + Items.Values.ElementAt(i); if (i != 0) { text = "," + text; } //allText += text; //textSize = TextSize(text, g); //if (_maxWidth < textSize.Width) _maxWidth = textSize.Width; /* * if (_enabled) * { * fontColor = Items.FontColor(Items.Keys.ElementAt(i)); * } * else * { * fontColor = Brushes.DarkSlateGray; * } * if (textSize.Width >= remainedSize) * { * float over = textSize.Width - remainedSize; * float rate = (remainedSize - over) / remainedSize; * int remained = (int)(text.Length * rate); * if (remained >= 3) * { * text = text.Substring(0, remained - 1); * text += "..."; * } * else * { * text = "..."; * } * * g.DrawString(text, _font, fontColor, cellBounds.X+(cellBounds.Width-remainedSize), cellBounds.Y + (cellBounds.Height - textSize.Height) / 2); * break; * } * else * { * g.DrawString(text, _font, fontColor, cellBounds.X + (cellBounds.Width - remainedSize), cellBounds.Y + (cellBounds.Height - textSize.Height) / 2); * } * remainedSize -= (int)textSize.Width; */ } base.Value = text; }