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

[Solved] GridViewMaskedTextBoxColumn problem

4 Answers 279 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fabiana
Top achievements
Rank 1
Fabiana asked on 26 Oct 2010, 06:41 PM
Hi support!!
I need to created a GridViewMaskedTextBoxColumn , but I noticed thar if I inserted this GridViewMaskedTextBoxColumn , gridView lost the mechanism of up arrow, down arrow in cell... Hot to change it... I can´t use Tab key...
Thanks!



<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="350" d:DesignWidth="525" MinHeight="350" MinWidth="525"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:telerikTheme="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
   xmlns:xx="clr-namespace:SilverlightApplication1" >

    <Grid x:Name="LayoutRoot" Margin="0,0,0,0">

        <telerik:RadGridView telerikTheme:StyleManager.Theme="Office_Blue" HorizontalAlignment="Stretch" Margin="24,53,22,0" Name="radGridView" VerticalAlignment="Stretch" SelectionUnit="Cell" IsTabStop="False" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn  Header="Name000" Width="*" DataMemberBinding="{Binding LastName}"/>
                <telerik:GridViewDataColumn Header="Name111" Width="*"  DataMemberBinding="{Binding LastName}"/>
                <telerik:GridViewMaskedTextBoxColumn Header="Idade" Width="*"  Mask="f" MaskType="Numeric"  DataMemberBinding="{Binding IdadeUser}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

    </Grid>
    
    
</UserControl>

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 Oct 2010, 08:02 AM
Hi Fabiana,

The reason for you not to be able to navigate out of the GridViewMaskedTextBoxColumn is that by default the property of the RadMaskedTextBox IsSpinEnabled is set to "True". So, in case you want to disable it, you may try to define the CellTemplate of a particular column to be RadMaskedTextBox and set this property to "False":

<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}">
  <telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
            <telerik:RadMaskedTextBox Mask="f" MaskType="Numeric" IsSpinEnabled="False"  Value="{Binding Number}" />
    </DataTemplate>
   </telerik:GridViewDataColumn.CellTemplate>                                          
</telerik:GridViewDataColumn>
 

Best wishes,
Maya
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
Fabiana
Top achievements
Rank 1
answered on 27 Oct 2010, 11:11 AM
Hi Maya!

I did your example and there is something very strange, because I click in cell to edit it, enter a new value, and when click in Down arrow, not move focus to neste cell... Please, can you reproduce it? What should I do ?

MainPage;xaml:



<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="350" d:DesignWidth="525" MinHeight="350" MinWidth="525"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:telerikTheme="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
   xmlns:xx="clr-namespace:SilverlightApplication1" >

   
    <Grid x:Name="LayoutRoot" Margin="0,0,0,0">

        <telerik:RadGridView telerikTheme:StyleManager.Theme="Office_Blue" HorizontalAlignment="Stretch" Margin="24,53,22,0" Name="radGridView" VerticalAlignment="Stretch" SelectionUnit="Cell" IsTabStop="False" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False">
         
            <telerik:RadGridView.Columns>
               
                <telerik:GridViewDataColumn  Header="First Name" Width="*" DataMemberBinding="{Binding FirstName}"/>
                <telerik:GridViewDataColumn Header="Last Name" Width="*"  DataMemberBinding="{Binding LastName}"/>
                <telerik:GridViewDataColumn Header="Age" Width="*" DataMemberBinding="{Binding IdadeUser}" >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadMaskedTextBox Mask="f" MaskType="Numeric" IsSpinEnabled="False" Value="{Binding IdadeUser}" Margin="0" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
               
            </telerik:RadGridView.Columns>
           
        </telerik:RadGridView>

    </Grid>
</UserControl>


-----------------------

NamedList.cs:



using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace SilverlightApplication1
{
    public class NameList : ObservableCollection<PersonName>
    {
        public NameList()
            : base()
        {
            Add(new PersonName("zzz", "11",2.6));
            Add(new PersonName("", "22",8.9));
            Add(new PersonName("", "33",9));
            Add(new PersonName("", "44",6));
            Add(new PersonName("", "55",5));
        }
    }

    public class PersonName : INotifyPropertyChanged
    {
        public PersonName(string first, string last, double idade)
        {
            this.firstName = first;
            this.lastName = last;
            this.idadeUser = idade;
        }

        private String firstName;
        public String FirstName
        {
            get
            {
                return this.firstName;
            }
            set
            {
                if (this.firstName != value)
                {
                    this.firstName = value;
                    OnPropertyChanged("FirstName");
                }
            }
        }

 

        private String lastName;
        public String LastName
        {
            get
            {
                return this.lastName;
            }
            set
            {
                if (this.lastName != value)
                {
                    this.lastName = value;
                    OnPropertyChanged("LastName");
                }
            }
        }

        private double idadeUser;

        public double IdadeUser
        {
            get
            {
                return this.idadeUser;
            }
            set
            {
                if (this.idadeUser != value)
                {
                    this.idadeUser = value;
                    OnPropertyChanged("IdadeUser");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

    }

}



0
Accepted
Maya
Telerik team
answered on 27 Oct 2010, 11:29 AM
Hi Fabiana,

May you try to set the CellEditTemplate of that particular column to be the RadMaskedTextBox instead of the CellTemplate ? 
 

Greetings,
Maya
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
Fabiana
Top achievements
Rank 1
answered on 27 Oct 2010, 11:45 AM
Maya, thanks! Now it´s perfect!!

http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=361070



<Grid x:Name="LayoutRoot" Margin="0,0,0,0">

        <telerik:RadGridView telerikTheme:StyleManager.Theme="Office_Blue" HorizontalAlignment="Stretch" Margin="24,53,22,0" Name="radGridView" VerticalAlignment="Stretch" SelectionUnit="Cell" IsTabStop="False" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False">
         
            <telerik:RadGridView.Columns>
               
                <telerik:GridViewDataColumn  Header="First Name" Width="*" DataMemberBinding="{Binding FirstName}"/>
                <telerik:GridViewDataColumn Header="Last Name" Width="*"  DataMemberBinding="{Binding LastName}"/>
                   <telerik:GridViewDataColumn Header="Age" Width="*" DataMemberBinding="{Binding IdadeUser, Mode=TwoWay}" >
                    <telerik:GridViewDataColumn.CellEditTemplate >
                        <DataTemplate>
                            <telerik:RadMaskedTextBox Mask="f" MaskType="Numeric" IsSpinEnabled="False"  Value="{Binding IdadeUser, Mode=TwoWay}" Margin="0" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate >
                </telerik:GridViewDataColumn>
               
            </telerik:RadGridView.Columns>
           
        </telerik:RadGridView>

    </Grid>

Tags
GridView
Asked by
Fabiana
Top achievements
Rank 1
Answers by
Maya
Telerik team
Fabiana
Top achievements
Rank 1
Share this question
or