This is a migrated thread and some comments may be shown as answers.

textwrap in cardView

5 Answers 88 Views
CardView
This is a migrated thread and some comments may be shown as answers.
Omar
Top achievements
Rank 1
Omar asked on 01 Feb 2019, 08:54 AM

Hi,

I have cardView that I am filling it with data manually (no data-binding).

I have problem in using text wrapping. See attached image.

as you can see the blue test is clipped, I need to display the entire test lets say in two line not one line. Can this be done?

Many thanks in advance.

Omar

 

 

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Feb 2019, 10:45 AM
Hello, Omar,       

In order to wrap the text in the CardViewItem, it is necessary to set the TextWrap property to true for the respective EditorItem. It is necessary to use the CardViewItemFormatting event. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/cardview/customizing-appearance/formatting-items 

private void radCardView1_CardViewItemFormatting(object sender, Telerik.WinControls.UI.CardViewItemFormattingEventArgs e)
{
    CardViewItem cardItem = e.Item as CardViewItem;
    if (cardItem != null)
    {
        cardItem.EditorItem.TextWrap = true;
    
}



I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Omar
Top achievements
Rank 1
answered on 02 Feb 2019, 08:28 PM

It works perfectly 

Many thanks.

0
Omar
Top achievements
Rank 1
answered on 04 Feb 2019, 08:08 PM

Hi, 

Just one more question.

If I want to format item forecolor with condition of its data, for example. I have item that hold a number, if this number is lower than 50 I want to color it with red else black.

Can this be done in CardView?

Best Regards,

Omar

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Feb 2019, 11:56 AM
Hello, Omar,         

The CardViewItemFormatting event is also suitable if you want customize the color of the item elements. You can find below a sample code snippet demonstrating how to make red the Ids that are greater than 3:

private void radCardView1_CardViewItemFormatting(object sender, Telerik.WinControls.UI.CardViewItemFormattingEventArgs e)
{
    CardViewItem cardItem = e.Item as CardViewItem;
    if (cardItem != null && cardItem.FieldName == "Id")
    {
        int id = 0;
        if (int.TryParse(cardItem.EditorItem.Text, out id) && id > 3)
        {
            e.Item.ForeColor = Color.Red;
        }
        else
        {
            e.Item.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }
    else
    {
        e.Item.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

Please have a look ate the following help article which demonstrates how to handle the CardViewItemFormatting event: https://docs.telerik.com/devtools/winforms/controls/cardview/customizing-appearance/formatting-items

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Omar
Top achievements
Rank 1
answered on 06 Feb 2019, 05:57 PM
Many thanks.
Tags
CardView
Asked by
Omar
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Omar
Top achievements
Rank 1
Share this question
or