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

TextBox Padding in GridViewCell's Edit Mode

11 Answers 282 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ye
Top achievements
Rank 1
Ye asked on 21 Jul 2011, 03:46 AM
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.


11 Answers, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 21 Jul 2011, 07:54 AM
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!

0
Ye
Top achievements
Rank 1
answered on 21 Jul 2011, 10:36 AM
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.
0
Ye
Top achievements
Rank 1
answered on 28 Jul 2011, 03:07 AM
    <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.
0
Stuart
Top achievements
Rank 1
answered on 29 Nov 2011, 05:43 PM
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?
0
Stuart
Top achievements
Rank 1
answered on 29 Nov 2011, 05:44 PM
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?
0
Sven J
Top achievements
Rank 2
answered on 04 Jun 2012, 08:31 AM
Hi,

has there been any update that resolves this problem?

Greetings
Sven
0
Vanya Pavlova
Telerik team
answered on 04 Jun 2012, 09:14 AM
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 >>

0
Sven J
Top achievements
Rank 2
answered on 06 Jun 2012, 09:58 AM
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
0
Vanya Pavlova
Telerik team
answered on 06 Jun 2012, 10:37 AM
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 >>

0
Sven J
Top achievements
Rank 2
answered on 06 Jun 2012, 11:22 AM
Hi,

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

Thanks again
Sven
0
Vanya Pavlova
Telerik team
answered on 06 Jun 2012, 01:04 PM
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 >>

Tags
GridView
Asked by
Ye
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Ye
Top achievements
Rank 1
Stuart
Top achievements
Rank 1
Sven J
Top achievements
Rank 2
Share this question
or