当前位置:网站首页>Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
2022-07-28 12:43:00 【Interface development Starling】
obtain DevExpress WinForms v22.1 Official download
Released by the official technical team v20.2 In the version cycle , Announced the availability of advanced text editor mode , Advanced text editor mode introduces many influential functions , Including caret / Choose animation support and embedded text labels . The future plan was detailed in the announcement at that time , And the official technical team will set it to the default editor mode after all reported problems are solved , Although this has not been set as the default mode , But the latest WXI The skin It is a big step towards this goal .

When WXI When the skin is activated , All text editors will switch to this advanced mode . In this regard , Colored text selection may be a clue , But it is certainly not the only reason for switching . In the new WXI In the skin , The editor uses additional background elements corresponding to different editor States , More elements mean additional client areas and boundary calculations 、 Increased boundary and content rendering logic and overall complexity . Solving these challenges in standard mode will produce side effects and artifacts , Therefore, the technical team decided to use the power of advanced mode to solve these problems .

stay WXI The skin The use of advanced patterns in has triggered around legacy code ( Designed for legacy 、 Code written in non Advanced Editor Mode ) Internal discussion of compatibility , Of course, the most concerned is MaskBox attribute . This property allows you to get standard WinForms Text box control (DevExpress WinForms TextEdit The foundation of the editor ), But in advanced mode TextEdits Is a complete custom control and is no longer based on Standards TextBoxes, Of these editors MaskBox Property returns null( stay VB.NET Empty in middle ).
The technical team shared many support center issues , To find the need to pass MaskBox Property to access the actual use case of the standard text box . According to research , Most of these cases fall into two main categories : Automatic completion and text processing ( Include custom input masks ).
Text auto complete
Now you can use this machine TextEditor API Use autocomplete , To introduce autocomplete , Please set up Editor.AdvancedModeOptions.AutoCompleteSource Property to specify whether the editor recommends entries from your custom data source or auto populate the source ( Recent projects 、 In the history list URL、 System file and folder names, etc ). You need to specify the appropriate mode (Suggest、Append、 A combination of the two or SuggestSingleWord), And assign custom data sources ( If you choose CustomSource Autocomplete mode ).
using DevExpress.XtraEditors;
void OnFormLoad(object sender, EventArgs e) {
var DaysOfTheWeek = new AutoCompleteStringCollection();
DaysOfTheWeek.AddRange(new string[]
{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"});
textEdit1.Properties.UseAdvancedMode = DevExpress.Utils.DefaultBoolean.True;
textEdit1.Properties.AdvancedModeOptions.AutoCompleteMode =
TextEditAutoCompleteMode.SuggestAppend;
textEdit1.Properties.AdvancedModeOptions.AutoCompleteSource =
AutoCompleteSource.CustomSource;
textEdit1.Properties.AdvancedModeOptions.AutoCompleteCustomSource = DaysOfTheWeek;
}Mask and text processing API
In the previous release cycle , We introduced a series of methods to help get and modify editor text :
- GetCharFromPosition(System.Drawing.Point)
- GetCharIndexFromPosition(System.Drawing.Point)
- GetFirstCharIndexFromLine(System.Int32)
- And others ( see also here Of TextEdit A complete list of methods )
These methods and Standards TextBox In the same way , for example TextBoxBase.GetCharFromPosition(Point). If you retrieve criteria TextBox To use its methods , Now you can use this machine TextEdit API To get the same result .
As for the low-level input mask , We recently added EnableCustomMaskTextInput Method , This method allows you to manually track user actions and assign editor values as needed .
for example , If you need to limit the number of bytes entered by the user , Previous versions required you to use rewritten TextEdit.CreateMaskBoxInstance Method to implement custom TextEdit Progeny , This method accepts customization TextBoxMaskBox object . then , This custom class will handle user input .
Use EnableCustomMaskTextInput Method , You no longer need any inheritance logic , Just check the byte length directly in the allocated callback .
using DevExpress.Data.Mask;
int m_maxByteLength = 5;
textEdit1.Properties.EnableCustomMaskTextInput(args => {
// Do nothing if no edits were made
if (args.IsCanceled || args.ActionType == CustomTextMaskInputAction.Init)
return;
if (GetByteLength(args.ResultEditText) > m_maxByteLength) {
args.Cancel();
return;
}
args.SetResult(
args.ResultEditText, args.ResultCursorPosition, args.ResultSelectionAnchor);
});
int GetByteLength(string text) {
return System.Text.Encoding.Default.GetBytes(text).Length;
}MaskBox Abandoning
To make a long story short , We updated TextEdit API It allows you to solve the problem that you need to use MaskBox All popular usage scenarios for attributes . This means that this attribute can now be discarded , But this attribute is not completely deleted , Invalidate your existing code . contrary , We now think that all are related to MaskBox Relevant scenes are out of date , And we suggest using our native editor API.
DevExpress WinForm | Download trial
DevExpress WinForm Have 180+ Components and UI library , for Windows Forms Platform to create influential business solutions .DevExpress WinForms It can perfectly build fluency 、 Beautiful and easy to use applications , Whether it's Office Style interface , Or analyze and process a large number of business data , It can be easily competent !
DevExpress Technology exchange group 6:600715373 Welcome to group discussion
边栏推荐
- Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held
- The input string contains an array of numbers and non characters, such as a123x456. Take the consecutive numbers as an integer, store them in an array in turn, such as 123 in a[0], 456 in a[1], and ou
- Developing NES games with C language (cc65) 11. Metatiles
- VS1003 debugging routine
- How to build knowledge management system in enterprises and institutions
- Hc-05 Bluetooth module debugging slave mode and master mode experience
- Hongjiu fruit passed the hearing: five month operating profit of 900million Ali and China agricultural reclamation are shareholders
- The usage and Simulation Implementation of vector in STL
- 20220728-Object类常用方法
- C structure use
猜你喜欢

Come to tdengine Developer Conference and have an insight into the future trend of data technology development

Uninstall Navicat: genuine MySQL official client, really fragrant!

Aopmai biological has passed the registration: the half year revenue is 147million, and Guoshou Chengda and Dachen are shareholders

苏黎世联邦理工学院 | 具有可变形注意Transformer 的基于参考的图像超分辨率(ECCV2022))

洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东

Hc-05 Bluetooth module debugging slave mode and master mode experience

Distributed session solution

30 years of open source community | 2022 open atom global open source summit 30 years of special activities of open source community were successfully held

GMT installation and use

Unity 安装 Device Simulator
随机推荐
Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held
Library automatic reservation script
Using dependent packages to directly implement paging and SQL statements
Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
公司在什么情况下可以开除员工
奥浦迈生物通过注册:半年营收1.47亿 国寿成达与达晨是股东
输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
MarkDown简明语法手册
How does musk lay off staff?
Most of the interfaces of Tiktok are already available, and more interfaces are still open. Please look forward to it
Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself
Let Arduino support nuvotom Xintang
Jinshanyun rushes to the dual main listing of Hong Kong stocks: the annual revenue of 9billion is a project supported by Lei Jun
Unity加载Glb模型
第九章 REST 服务安全
用C语言开发NES游戏(CC65)08、背景 碰撞
Developing NES games (cc65) 05 and palette with C language
Four authentic postures after suffering and trauma, Zizek
C# 泛型是什么、泛型缓存、泛型约束
Basic use of JSON server