rt

解决方案 »

  1.   

        <%#Eval("dis_content").ToString().Length>25?((Eval("dis_content")).ToString().Substring(0,25))+"…":((Eval("dis_content")).ToString())  %>
                    
                                                          
                                                                                    
      

  2.   

    给个方法: 
    <asp:Label ID="lblProjName" Text='<%#(Eval(" XXX").ToString(),25) %>' 
    ToolTip='<%# Eval("XXX").ToString() %>' runat="server"></asp:Label>
      

  3.   

    是WinForm的问题。
    还有 我要的效果是当字符串不能完全显示的时候,显示部分字符串,然后加上"..."。好像有个Format 或者什么的有个这样的属性
      

  4.   

    在DataBind后用循环取出你要显示那一列值
    if(dataGridView.Rows[行索引].Cells[列索引].Value.Tostring().Length>25)
        dataGridView.Rows[行索引].Cells[列索引].Value=dataGridView.Rows[行索引].Cells[列索引].Value.Tostring().Substring(0,25))+"...";
      

  5.   

    不是很懂ASP,一楼的方法是字符串替换么?既然是表格控件,就有可能进行运算,替换字符串,显然不可取
      

  6.   

    你仔细看看哪里是替换了?你进行计算难道不是取整个单元格的值,然后比较字符串的长度?
    取到单元格的值先对值的长度进行判断//下面是判断如果长度大于30个字节,就显示前30个字节+...
    if(dataGridView.Rows[行索引].Cells[列索引].Value.Tostring().Length>30)     dataGridView.Rows[行索引].Cells[列索引].Value=dataGridView.Rows[行索引].Cells[列索引].Value.Tostring().Substring(0,30))+"..."; Substring是截取字符串,不是替换
      

  7.   

    winform        void YourDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                String DataPropertyName = YourDataGridView.Columns[e.ColumnIndex].DataPropertyName;             if (DataPropertyName == "XXX") // 要缩略的数据列
                       if (e.Value.Length>25) // 这里简单写个
                           e.Value = e.Value.ToString().Substring(0, 25)+"...";  
            }
      

  8.   

    在databound里
    判断e.item.cells[0].text显示...
      

  9.   

    [Quote=引用 7 楼 wangping_li 的回复:]
     dataGridView.Rows[行索引].Cells[列索引].Value=dataGridView.Rows[行索引].Cells[列索引].Value.Tostring().Substring(0,30))+"..."; 
    Quote]有赋值了!
    看来只有重写DataGridTextBoxColumn列了,在Paint事件中添加如下代码//.Net FrameWork SDK 强大啊StringFormat format    = new StringFormat();
    //正行显示
    format.FormatFlags = StringFormatFlags.LineLimit;
    //移除结尾并以“...”代替
    format.Trimming = StringTrimming.EllipsisCharacter;
      

  10.   

    我整理了一下
    http://blog.csdn.net/assky124/archive/2008/11/26/3380528.aspx
      

  11.   

    真不知道你们这些人回复时都不看问题的,别人问的是winfrom
    如果是B/S的还用问,
      

  12.   

    这种问题没必要搞那么复杂,也不用重写什么DataGridTextBoxColumn,你设为不让用户调整列的大小不就好了?
    很简单的一个长度截取+"..."
      

  13.   

    奇怪了,
    我这里的GridView单元格是自动有"..."的.呵呵...都不用写代码了,自动有
      

  14.   

    为了表现部分改变,值是有显而易见的问题,如果有人调用你的DataGrid进行更新怎么办,GridView 是VS2005的,和DataGrid是两个不同的控件;