diff --git a/CommonControls/DataTab.Designer.cs b/CommonControls/DataTab.Designer.cs index aba5b64..0db2ce7 100644 --- a/CommonControls/DataTab.Designer.cs +++ b/CommonControls/DataTab.Designer.cs @@ -74,7 +74,7 @@ private void InitializeComponent() // txtSize // this.txtSize.Location = new System.Drawing.Point(211, 16); - this.txtSize.MaxLength = 3; + this.txtSize.MaxLength = 5; this.txtSize.Name = "txtSize"; this.txtSize.Size = new System.Drawing.Size(40, 20); this.txtSize.TabIndex = 34; diff --git a/CommonControls/DataTab.cs b/CommonControls/DataTab.cs index 1844d55..eebd027 100644 --- a/CommonControls/DataTab.cs +++ b/CommonControls/DataTab.cs @@ -56,12 +56,13 @@ public ushort DataLength ushort rVal = 64; try { - if (txtSize.Text.IndexOf("0x", 0, txtSize.Text.Length) == 0) + if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)) { string str = txtSize.Text.Replace("0x", ""); rVal = Convert.ToUInt16(str, 16); } - rVal = Convert.ToUInt16(txtSize.Text); + else + rVal = Convert.ToUInt16(txtSize.Text); } catch (Exception) { @@ -71,7 +72,13 @@ public ushort DataLength } set { - txtSize.Text = Convert.ToString(value); + if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)) + { + // obey hex input + txtSize.Text = "0x"+Convert.ToString(value, 16); + } + else + txtSize.Text = Convert.ToString(value); } }