C# 为什么填充的DataGridView单元格(DataGridViewTextBoxCell实例)显示省略号点?

C# 为什么填充的DataGridView单元格(DataGridViewTextBoxCell实例)显示省略号点?,c#,winforms,datagridview,formatting,datagridviewtextboxcell,C#,Winforms,Datagridview,Formatting,Datagridviewtextboxcell,当我用值填充DataGridView中的选定单元格时,例如“1”,而不是简单地显示“1”,它们会显示“1…” 为什么会出现这种情况,如何防止省略号点显示 更新 这是请求的代码(如下)。它看起来是什么样子的尖叫镜头(暂停,出于某种原因,posterous不接受它作为一个点碰撞或jay peg) 无论如何,DGV看起来是这样的: 00:00 | 1... 00:15 | 00:30 | 1... 00:45 | 1... …应在何时: 00:00 | 1 00:15 | 00:30 | 1 0

当我用值填充DataGridView中的选定单元格时,例如“1”,而不是简单地显示“1”,它们会显示“1…”

为什么会出现这种情况,如何防止省略号点显示

更新 这是请求的代码(如下)。它看起来是什么样子的尖叫镜头(暂停,出于某种原因,posterous不接受它作为一个点碰撞或jay peg)

无论如何,DGV看起来是这样的:

00:00 | 1...
00:15 | 
00:30 | 1...
00:45 | 1...
…应在何时:

00:00 | 1
00:15 | 
00:30 | 1
00:45 | 1
正如在最后一行的评论中所指出的,电话值与测试数据仅为“1”。将鼠标悬停在该值上会显示工具提示/提示“1”(而不是“1…”或类似内容)

private void CreateandPopulatedGVPlatyPussScheduleCells()
{
//添加所需的列
如果(DataGridViewPlatyPussSchedule.Columns.Count==0){
对于(int i=0;idgvr.Cells[colName].Value=phoneVal;//我使用了引用的msdn代码,但合并了StringFormat对象,并将花哨的深红色和蓝色替换为黑色(用于内容字体)和blanchedalmond,以融入我的网格。我从msdn代码中更改的三件事被注意/注释:

private void dataGridViewLifeSchedule_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
    // 1. This is used to replace what is StringFormat.GenericDefault in the msdn code with strFormat
    StringFormat strFormat = new StringFormat();
    strFormat.Trimming = StringTrimming.None; 

    Rectangle newRect = new Rectangle(e.CellBounds.X + 1,
    e.CellBounds.Y + 1, e.CellBounds.Width - 4,
    e.CellBounds.Height - 4);

    using (
        Brush gridBrush = new SolidBrush(this.dataGridViewLifeSchedule.GridColor),
        backColorBrush = new SolidBrush(e.CellStyle.BackColor)) {
        using (Pen gridLinePen = new Pen(gridBrush)) {
            // Erase the cell.
            e.Graphics.FillRectangle(backColorBrush, e.CellBounds);

            // Draw the grid lines (only the right and bottom lines; 
            // DataGridView takes care of the others).
            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
                e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
                e.CellBounds.Bottom - 1);
            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
                e.CellBounds.Top, e.CellBounds.Right - 1,
                e.CellBounds.Bottom);

            // Draw the inset highlight box.
            e.Graphics.DrawRectangle(Pens.BlanchedAlmond, newRect); // 2. It is Pens.Blue in the msdn code

            // Draw the text content of the cell, ignoring alignment. 
            if (e.Value != null) {
                e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
                    Brushes.Black, e.CellBounds.X + 2, // 3. It is Brushes.Crimson in the msdn code
                    e.CellBounds.Y + 2, strFormat);
            }
            e.Handled = true;
        }
    }
}
private void dataGridViewLifeSchedule_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
    // 1. This is used to replace what is StringFormat.GenericDefault in the msdn code with strFormat
    StringFormat strFormat = new StringFormat();
    strFormat.Trimming = StringTrimming.None; 

    Rectangle newRect = new Rectangle(e.CellBounds.X + 1,
    e.CellBounds.Y + 1, e.CellBounds.Width - 4,
    e.CellBounds.Height - 4);

    using (
        Brush gridBrush = new SolidBrush(this.dataGridViewLifeSchedule.GridColor),
        backColorBrush = new SolidBrush(e.CellStyle.BackColor)) {
        using (Pen gridLinePen = new Pen(gridBrush)) {
            // Erase the cell.
            e.Graphics.FillRectangle(backColorBrush, e.CellBounds);

            // Draw the grid lines (only the right and bottom lines; 
            // DataGridView takes care of the others).
            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
                e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
                e.CellBounds.Bottom - 1);
            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
                e.CellBounds.Top, e.CellBounds.Right - 1,
                e.CellBounds.Bottom);

            // Draw the inset highlight box.
            e.Graphics.DrawRectangle(Pens.BlanchedAlmond, newRect); // 2. It is Pens.Blue in the msdn code

            // Draw the text content of the cell, ignoring alignment. 
            if (e.Value != null) {
                e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
                    Brushes.Black, e.CellBounds.X + 2, // 3. It is Brushes.Crimson in the msdn code
                    e.CellBounds.Y + 2, strFormat);
            }
            e.Handled = true;
        }
    }
}