TextBox Padding in GridViewCell's Edit Mode

12 posts, 1 answers
  1. Ye
    Ye avatar
    23 posts
    Member since:
    Dec 2010

    Posted 20 Jul 2011 Link to this post

    I modified the default style of GridViewCell and set the fontSize to 14 like this
    <Setter Property="FontSize" Value="14" />
    
    There is an issue when the GridViewCell is in Edit mode, the row's height will be heighter than others.
    I found that the textBox in edit mode has an padding whose value is "2,2,2,2"。 How can i change the textBox's padding value.
    Or what can I do to set the rows in the same height.
    Waiting for your help.


  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 21 Jul 2011 Link to this post

    Hi Ye,

     

    When the GridViewCell goes into edit mode the standard TextBox control appeared. You may create an implicit style targeted at a single TextBox and set the desired properties from there. RadGridView will handle these settings correspondingly. Furthermore if you want to set a fixed height for all rows you may do this through setting RadGridView's RowHeight property to a desired value. 


    Hope this helps! 


    Greetings,
    Vanya Pavlova
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. Ye
    Ye avatar
    23 posts
    Member since:
    Dec 2010

    Posted 21 Jul 2011 Link to this post

    I know it is TextBox control when it is in edit mode.
    But i really don't how to let the gridviewcell to know which textBox style to use.

    And can you give me an example.
    Any code is helpful.
  5. Ye
    Ye avatar
    23 posts
    Member since:
    Dec 2010

    Posted 27 Jul 2011 Link to this post

        <Style TargetType="TextBox">
            <Setter Property="Padding" Value="0"/>
        </Style>

    I add style like this,but it is useless.
    Take a look at this, what should i do.
  6. Stuart
    Stuart avatar
    3 posts
    Member since:
    May 2011

    Posted 29 Nov 2011 Link to this post

    I have similar issue. I want to change text box style in the grid but it doesn't work.
    Does anyone have answer for this?
  7. Stuart
    Stuart avatar
    3 posts
    Member since:
    May 2011

    Posted 29 Nov 2011 Link to this post

    I have similar issue. I want to change text box style in the grid but it doesn't work.
    Does anyone have answer for this?
  8. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 04 Jun 2012 Link to this post

    Hi,

    has there been any update that resolves this problem?

    Greetings
    Sven
  9. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 04 Jun 2012 Link to this post

    Hi Sven,

     

    For the time being as a kind of workaround I may suggest you to manually set the template of the TextBox as shown below:

    <UserControl.Resources>
            <ControlTemplate x:Key="s1" TargetType="TextBox">
                <Border Background="Yellow" BorderBrush="Red" BorderThickness="1" CornerRadius="0">
                    <ContentPresenter Content="{TemplateBinding Text}"/>
                </Border>
            </ControlTemplate>
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadGridView Name="radGridView"
                         AutoGenerateColumns="False" ItemsSource="{Binding}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name"
                                        DataMemberBinding="{Binding Name}">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                        <telerik:GridViewDataColumn.CellEditTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Name}" Template="{StaticResource s1}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="Est."
                                        DataMemberBinding="{Binding Established}" />
     
                    <telerik:GridViewDataColumn Header="Stadium"
                                        DataMemberBinding="{Binding StadiumCapacity}"
                                        DataFormatString="{}{0:N0}" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>

    All the best,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  10. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 06 Jun 2012 Link to this post

    Hi,

    Is there also a generic way to solve this? I use an inherited version of RadGridView so I could customize code there... 

    Thank you
    Sven
  11. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 06 Jun 2012 Link to this post

    Hi Sven,

     


    You have a variety of options to access the columns in your inherited grid and set the desired DataTemplate from code-behind. Within this template you may set the desired ControlTemplate of the TextBox to achieve your goal. 



    All the best,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  12. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 06 Jun 2012 Link to this post

    Hi,

    could you please provide a short code snippet to give me a little jump start?

    Thanks again
    Sven
  13. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 06 Jun 2012 Link to this post

    Hello Sven,

     

    I have prepared very simple and basic example which demonstrates how to achieve this.
    Please take a look at the attachment and let me know if you need any additional information.   



    All the best,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner