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

Adding a TextBox to GridView

4 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sean Wright
Top achievements
Rank 1
Sean Wright asked on 05 May 2010, 06:26 PM
Hello,

I don't know why I can't find the answer to this anywhere online or in various Help resources, but here is the problem: I have a RadGridView in Silverlight. The majority of the columns are bound to a datasource, however, I need to have the very last column contain an empty TextBox which users can input text into. I can't figure out how to add a TextBox control to the column, though.

Here is the GridView code. Can anyone tell me the syntax to insert a TextBox into that last column, the one whose HeaderText property is "Comments"?

Thank you very much:

    <Grid x:Name="LayoutRoot" Margin="0,0,8,8">
   <Controls:RadGridView x:Name="theResultsGrid" AutoGenerateColumns="False" MinHeight="100" IsReadOnly="True" d:LayoutOverrides="GridBox" Margin="0,0,8,53" >
   <Controls:RadGridView.Columns>
    <Controls:GridViewDataColumn HeaderText="Est. Code" DataMemberBinding="{Binding Path=EstimateCode}"/> 
    <Controls:GridViewDataColumn HeaderText="Order" DataMemberBinding="{Binding Path=EntryOrder}"/> 
    <Controls:GridViewDataColumn HeaderText="PcMk" DataMemberBinding="{Binding Path=PieceMarkConnectionCode}"/> 
    <Controls:GridViewDataColumn HeaderText="Drawing" DataMemberBinding="{Binding Path=Drawing}"/>
    <Controls:GridViewDataColumn HeaderText="Material Desc." DataMemberBinding="{Binding Path=AiscMaterial}"/>
    <Controls:GridViewDataColumn HeaderText="Grade" DataMemberBinding="{Binding Path=Grade}"/>
    <Controls:GridViewDataColumn HeaderText="SP" DataMemberBinding="{Binding Path=IsShipped}"/>
    <Controls:GridViewDataColumn HeaderText="MM" DataMemberBinding="{Binding Path=IsMainMember}"/>
    <Controls:GridViewDataColumn HeaderText="Material Wt." DataMemberBinding="{Binding Path=MaterialWeight}"/>
    <Controls:GridViewDataColumn HeaderText="Qty" DataMemberBinding="{Binding Path=MaterialQuantity}"/>
    <Controls:GridViewDataColumn HeaderText="Material Connection" DataMemberBinding="{Binding Path=MaterialConnections}"/>
    <Controls:GridViewDataColumn HeaderText="Length" DataMemberBinding="{Binding Path=Length}"/>
    <Controls:GridViewDataColumn HeaderText="Width" DataMemberBinding="{Binding Path=Width}"/>
    <Controls:GridViewDataColumn HeaderText="PricePerPound" DataMemberBinding="{Binding Path=PricePerPound}"/>
    <Controls:GridViewDataColumn HeaderText="Unit Price" DataMemberBinding="{Binding Path=UnitPrice}"/>
    <Controls:GridViewDataColumn HeaderText="Shop Shorthand" DataMemberBinding="{Binding Path=ShopShorthand}"/>
                <Controls:GridViewDataColumn HeaderText="Labor Qty" DataMemberBinding="{Binding Path=LaborQuantity}"/>
                <Controls:GridViewDataColumn HeaderText="Shop Hours" DataMemberBinding="{Binding Path=ShopHours}"/>
    <Controls:GridViewDataColumn HeaderText="Field Shorthand" DataMemberBinding="{Binding Path=FieldShorthand}"/>
    <Controls:GridViewDataColumn HeaderText="Field Hours" DataMemberBinding="{Binding Path=FieldHours}"/>
    <Controls:GridViewDataColumn HeaderText="Det. Hours" DataMemberBinding="{Binding Path=DetailingHours}"/>
    <Controls:GridViewColumn HeaderText="Comments"/>     
   </Controls:RadGridView.Columns>
  </Controls:RadGridView>

4 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 06 May 2010, 07:38 AM
Hello Sean Wright,

You can use the CellTemplate property of our columns to customize what elements are shown in a column. For example:

<telerikGrid:GridViewColumn Header="Name">
   <telerikGrid:GridViewColumn.CellTemplate>
       <DataTemplate>
           <StackPanel Orientation="Horizontal">
               <Image Stretch="None"
                      Source="../../Images/User.png"
                      Margin="0,0,5,0" />
               <TextBlock Text="{Binding Name}"
                          VerticalAlignment="Center" />
           </StackPanel>
       </DataTemplate>
   </telerikGrid:GridViewColumn.CellTemplate>
</telerikGrid:GridViewColumn>


Kind regards,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sean Wright
Top achievements
Rank 1
answered on 11 May 2010, 05:53 PM
Thank you. I'll try it out and see how well it works. I appreciate your response.
0
Johnny
Top achievements
Rank 1
answered on 19 Jan 2012, 12:58 AM
Hi Sean,

Did this example work out for you? I am trying to make a gridview for my website, using silverlight, that has a few columns as a text filed and let the users to input either a number or string of text. My problem is after input a string of text into the text field, those text won't stay there after i click anywhere inside the GridView
0
Maya
Telerik team
answered on 19 Jan 2012, 07:25 AM
Hello Johnny,

I have just replied to the other forum thread you started on a similar topic. Please take a look at it and let me know in case you need any further assistance. 


All the best,
Maya
the Telerik team

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

Tags
GridView
Asked by
Sean Wright
Top achievements
Rank 1
Answers by
Milan
Telerik team
Sean Wright
Top achievements
Rank 1
Johnny
Top achievements
Rank 1
Maya
Telerik team
Share this question
or