A
A
Artyom Pletnev2013-11-22 16:23:13
Microsoft Silverlight
Artyom Pletnev, 2013-11-22 16:23:13

How to dynamically create columns in RadGridView?

Good evening everyone, habravchane. Forgive the young and inexperienced, but the problem is the following:
you need to dynamically create a table in which: 31 columns (30 or 28 depending on the month). Each column has 4 controls: 2 textboxes for reading and 2 textboxes for entering.
Example:
SnimokPNG_1255249_9820015.png
Data is stored in a sheet. Binding needs to be configured. =)
.Net 4.5; C#; Silverlight 5;
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Pletnev, 2013-11-25
@Aptem_Pletnev

Found a solution:

IrregGridView.Columns.Add(new GridViewDataColumn()
                                                                                       {
                                                                                           Header = x.DayNumber.ToString(),
                                                                                           HeaderTextAlignment = TextAlignment.Center,
                                                                                           TextAlignment = TextAlignment.Center,
                                                                                           Width = GridViewLength.Auto,
                                                                                           IsFilterable = false,   
                                                                                           CellTemplate = (System.Windows.DataTemplate)
                                                                                                            XamlReader.Load(@"<DataTemplate 
                                                                                                            xmlns='http://schemas.microsoft.com/client/2007'  
                                                                                                            xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
                                                                                                            <StackPanel Orientation=""Vertical"">
                                                                                                                <TextBox Width=""28"" Height=""22"" Text=""{Binding Path= ModelVLimit}"" IsReadOnly=""true""
                                                                                                                                       TextAlignment=""Center"" FontSize=""9"" />
                                                                                                                <TextBox Width=""28"" Height=""22"" Text=""2"" IsReadOnly=""true""
                                                                                                                                       TextAlignment=""Center"" FontSize=""9"" />
                                                                                                                <TextBox Width=""28"" Height=""22"" Text=""3"" IsReadOnly=""false""
                                                                                                                                       TextAlignment=""Center"" FontSize=""9"" />
                                                                                                                <TextBox Width=""28"" Height=""22"" Text=""4"" IsReadOnly=""false""
                                                                                                                                       TextAlignment=""Center"" FontSize=""9""  />
                                                                                                            </StackPanel> </DataTemplate>")
                                                                                       });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question