作成日: 2014/08/13 最終更新日: 2014/09/16
文書種別
不具合
状況
修正済み
詳細
Formatプロパティに"F1"などを指定して小数点以下の入力を許可したC1NumericBoxコントロールにおいて、[-][0][.][3]の順に入力すると、「-0.3」ではなく「0.3」として入力されます。[0][.][3][-]の順に入力した場合は、入力後の値も「-0.3」となります。
回避方法
この問題はバージョン4.0.20142.413で修正されました。
修正版の適用方法については、アップデートの方法を参照してください。
修正版を適用しない場合の回避方法は次の通りです。
C1NumericBoxを継承したカスタムC1NumericBoxを作成し、そのKeyDownおよびKeyUpイベントを使用して、必要に応じてコントロールのテキストを再設定します。
◎サンプルコード(C#)
◎サンプルコード(VB)
修正版の適用方法については、アップデートの方法を参照してください。
修正版を適用しない場合の回避方法は次の通りです。
C1NumericBoxを継承したカスタムC1NumericBoxを作成し、そのKeyDownおよびKeyUpイベントを使用して、必要に応じてコントロールのテキストを再設定します。
◎サンプルコード(C#)
using C1.WPF;
using System;
using System.Windows.Input;
class CustomC1NumericBox : C1NumericBox
{
string buftext = string.Empty;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var textBox = this.GetTemplateChild("Text") as C1TextBoxBase;
if(textBox != null)
{
textBox.KeyUp += this.txt_KeyUp;
textBox.KeyDown += this.txt_KeyDown;
}
}
void txt_KeyDown(object sender, KeyEventArgs e)
{
C1TextBoxBase textBox = sender as C1TextBoxBase;
if (textBox != null)
buftext = textBox.C1Text;
}
void txt_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.OemPeriod || e.Key == Key.Decimal)
{
C1TextBoxBase textBox = sender as C1TextBoxBase;
if (textBox != null)
{
if (textBox.C1Text == ".0" && buftext.StartsWith("-"))
{
textBox.C1Text = "-0.0";
textBox.SelectionStart = 3;
}
}
}
}
}
using System;
using System.Windows.Input;
class CustomC1NumericBox : C1NumericBox
{
string buftext = string.Empty;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var textBox = this.GetTemplateChild("Text") as C1TextBoxBase;
if(textBox != null)
{
textBox.KeyUp += this.txt_KeyUp;
textBox.KeyDown += this.txt_KeyDown;
}
}
void txt_KeyDown(object sender, KeyEventArgs e)
{
C1TextBoxBase textBox = sender as C1TextBoxBase;
if (textBox != null)
buftext = textBox.C1Text;
}
void txt_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.OemPeriod || e.Key == Key.Decimal)
{
C1TextBoxBase textBox = sender as C1TextBoxBase;
if (textBox != null)
{
if (textBox.C1Text == ".0" && buftext.StartsWith("-"))
{
textBox.C1Text = "-0.0";
textBox.SelectionStart = 3;
}
}
}
}
}
◎サンプルコード(VB)
Imports C1.WPF
Public Class CustomC1NumericBox
Inherits C1NumericBox
Dim buftext As String = String.Empty
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
Dim textBox As C1TextBoxBase = CType(Me.GetTemplateChild("Text"), C1TextBoxBase)
If Not textBox Is Nothing Then
AddHandler textBox.KeyDown, AddressOf Me.txt_KeyDown
AddHandler textBox.KeyUp, AddressOf Me.txt_KeyUp
End If
End Sub
Sub txt_KeyDown(sender As Object, e As KeyEventArgs)
Dim textBox As C1TextBoxBase = CType(sender, C1TextBoxBase)
If Not textBox Is Nothing Then
buftext = textBox.C1Text
End If
End Sub
Sub txt_KeyUp(sender As Object, e As System.Windows.Input.KeyEventArgs)
If e.Key = Key.OemPeriod Or e.Key = Key.Decimal Then
Dim textBox As C1TextBoxBase = CType(sender, C1TextBoxBase)
If Not textBox Is Nothing Then
If textBox.C1Text = ".0" And buftext.StartsWith("-") Then
textBox.C1Text = "-0.0"
textBox.SelectionStart = 3
End If
End If
End If
End Sub
End Class
Public Class CustomC1NumericBox
Inherits C1NumericBox
Dim buftext As String = String.Empty
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
Dim textBox As C1TextBoxBase = CType(Me.GetTemplateChild("Text"), C1TextBoxBase)
If Not textBox Is Nothing Then
AddHandler textBox.KeyDown, AddressOf Me.txt_KeyDown
AddHandler textBox.KeyUp, AddressOf Me.txt_KeyUp
End If
End Sub
Sub txt_KeyDown(sender As Object, e As KeyEventArgs)
Dim textBox As C1TextBoxBase = CType(sender, C1TextBoxBase)
If Not textBox Is Nothing Then
buftext = textBox.C1Text
End If
End Sub
Sub txt_KeyUp(sender As Object, e As System.Windows.Input.KeyEventArgs)
If e.Key = Key.OemPeriod Or e.Key = Key.Decimal Then
Dim textBox As C1TextBoxBase = CType(sender, C1TextBoxBase)
If Not textBox Is Nothing Then
If textBox.C1Text = ".0" And buftext.StartsWith("-") Then
textBox.C1Text = "-0.0"
textBox.SelectionStart = 3
End If
End If
End If
End Sub
End Class
旧文書番号
80919