Replace all TextBlock with another control

4 posts, 1 answers
  1. Ahmad
    Ahmad avatar
    26 posts
    Member since:
    May 2015

    Posted 25 Dec 2016 Link to this post

    Hi,
    I wanna replace all TextBlock controls used in RadGridViews in my application with another control.
    for example: if cell is string instead of TextBlock, use RichTextBox.
    there is any way to do that?
    Thanks.
  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1183 posts

    Posted 26 Dec 2016 Link to this post

    Hi,

    There are several different possible approaches to this task. You can create a custom column, overriding CreateCellElement. You can also use the DataTemplate support, by using CellTemplate, or CellTemplateSelector.  If the scenario requires that all TextBlocks should be replaced, I would recommend the custom column approach.
    As a side note, I would like to mention that RichTextBox is a very complex control and using it in every cell of RadGridView will significantly affect performance. Can you please share what is your ultimate goal, so that we can discuss an alternative approach if it is possible.

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Ahmad
    Ahmad avatar
    26 posts
    Member since:
    May 2015

    Posted 27 Dec 2016 Link to this post

    Hi,
    The TextBlock have some problem when you type words in different languages.
    for example, if you type Arabic word first and after that, you type an English word,
    it seems you type English word first.
    I fix it using RichTextBox.
    So I wanna use this control instead of TextBlock in RadGridView.
    Thanks.
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1183 posts

    Posted 27 Dec 2016 Link to this post

    Hello,

    You can try using a RichTextBox, but if the performance is not satisfying enough, I would suggest that you try using a custom user control that solves the problem. Can you please confirm whether you want to display it in edit, or display mode, as you mentioned that the issue occurs when typing?

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top