limit colunm width in gridview

G

graphicsxp

Hi,
I've come across a few solutions on the forum for this problem but it
still don't work :(

I have a column that can contains very long text value. I was hoping
the value would be truncated to the size of the column's width. So I
did the following :

Protected Sub grdCuttings_RowCreated(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
grdCuttings.RowCreated
Dim iWidth As Integer = 100
If e.Row.RowType = DataControlRowType.DataRow Then
For r As Integer = 0 To Me.grdCuttings.Columns.Count - 1
Me.grdCuttings.Columns(r).ItemStyle.Width = iWidth
Me.grdCuttings.Columns(r).ItemStyle.Wrap = False
Next
End If
End Sub
It changes the width but the text is wrapped instead of being
truncated..

Can you help ?
 
F

Flinky Wisty Pomm

Um... you can't really... actually that's not true.

You can specify a number of characters to place in the field, but your
users may have different font settings to you, and their text will wrap
anyway.

You can try setting the no-wrap CSS attribute on your cells and
specifying overflow: hidden; but I don't know how well that will work.
It's not the sort of thing you tend to do very often on a webpage.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top