8 Answers, 1 is accepted
0
Hi Andreas,
Thank you for writing us.
Currently RadGridView does not support line breaks and word wrapping for its cells content. This is a high priority feature and we are in process of implementing it for one of our upcoming releases. In the meantime you can use the following workaround.
You can insert Label controls in the cells where you want to have text with line breaks.
The code snippet below demonstrates this technique:
In case you have further questions, don't hesitate to contact us.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for writing us.
Currently RadGridView does not support line breaks and word wrapping for its cells content. This is a high priority feature and we are in process of implementing it for one of our upcoming releases. In the meantime you can use the following workaround.
You can insert Label controls in the cells where you want to have text with line breaks.
The code snippet below demonstrates this technique:
this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); |
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement.ColumnInfo is GridViewTextBoxColumn && |
((GridViewTextBoxColumn)e.CellElement.ColumnInfo).DataField == "Name") |
{ |
if (e.CellElement.Children.Count == 0) |
{ |
Label label = new Label(); |
label.Text = e.CellElement.Value.ToString(); |
label.ForeColor = Color.Black; |
RadHostItem item = new RadHostItem(label); |
e.CellElement.Children.Add(item); |
e.CellElement.ForeColor = Color.Transparent; |
} |
else |
{ |
Label label = (Label)((RadHostItem)e.CellElement.Children[0]).HostedControl; |
label.ForeColor = Color.Black; |
label.Text = e.CellElement.Value.ToString(); |
} |
} |
} |
In case you have further questions, don't hesitate to contact us.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
andi
Top achievements
Rank 1
answered on 29 Jan 2008, 10:56 AM
hi jack,
thanks for xour answer! could you post the code as visual basic code please?
thank you! andreas
thanks for xour answer! could you post the code as visual basic code please?
thank you! andreas
0
Hi Andreas,
Here is the same code in VB (you can use the free code converter that Telerik provides here):
Do not hesitate to write us if you need further assistance.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Here is the same code in VB (you can use the free code converter that Telerik provides here):
Private Sub radGridView1_CellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs) |
If TypeOf e.CellElement.ColumnInfo Is GridViewTextBoxColumn AndAlso DirectCast(e.CellElement.ColumnInfo, GridViewTextBoxColumn).DataField = "Name" Then |
If e.CellElement.Children.Count = 0 Then |
Dim label As New Label() |
label.Text = e.CellElement.Value.ToString() |
label.ForeColor = Color.Black |
Dim item As New RadHostItem(label) |
e.CellElement.Children.Add(item) |
e.CellElement.ForeColor = Color.Transparent |
Else |
Dim label As Label = DirectCast(DirectCast(e.CellElement.Children(0), RadHostItem).HostedControl, Label) |
label.ForeColor = Color.Black |
label.Text = e.CellElement.Value.ToString() |
End If |
End If |
End Sub |
Do not hesitate to write us if you need further assistance.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
andi
Top achievements
Rank 1
answered on 29 Jan 2008, 01:24 PM
thank you very mutch!
i still have two problems:
1. Type 'RadHostItem' is not denfined
2. how do i call the sub that you posted in my code?
thanks again,
andreas
i still have two problems:
1. Type 'RadHostItem' is not denfined
2. how do i call the sub that you posted in my code?
thanks again,
andreas
0
Hi Andy,
Here is the answer to your questions:
Regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Here is the answer to your questions:
- Add the following code on top of your class definition in order to import the Telerik.WinControls namespace:
Imports Telerik.WinControls - The following code construction shows how to attach the RadGridView1_CellFormatting function to the CellFormatting event of the RadGridView:
AddHandler Me.RadGridView1.CellFormatting, AddressOf RadGridView1_CellFormatting
Regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
andi
Top achievements
Rank 1
answered on 29 Jan 2008, 03:09 PM
ok, i added the code but nothing happens. don't i have to do anything else?
andreas
andreas
0
andi
Top achievements
Rank 1
answered on 29 Jan 2008, 03:18 PM
i'm sorry, the post before was wrong. there happened something ;)
but now i have the problem that the height of the row is to small. how can i change this?
thanks, andras
but now i have the problem that the height of the row is to small. how can i change this?
thanks, andras
0
Hello Andreas,
We have answered your question in this forum post.
Regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
We have answered your question in this forum post.
Regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center