当前位置:网站首页>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
边栏推荐
- Come to tdengine Developer Conference and have an insight into the future trend of data technology development
- 03 pyechars 直角坐标系图表(示例代码+效果图)
- Most of the interfaces of Tiktok are already available, and more interfaces are still open. Please look forward to it
- 【一知半解】零值拷贝
- The openatom openharmony sub forum was successfully held, and ecological and industrial development entered a new journey
- 合并表格行---三层for循环遍历数据
- Unity 安装 Device Simulator
- Implementation method of mouse hover, click and double click in ue4/5
- 05 pyechars 基本图表(示例代码+效果图)
- Open source office (ospo) unveils Secrets
猜你喜欢

Basic use of JSON server

【萌新解题】爬楼梯

Unity 安装 Device Simulator

C for循环内定义int i变量出现的重定义问题

Developing NES game (cc65) 07 and controller with C language

How does musk lay off staff?

AVL tree (balanced search tree)

How to realize more multimedia functions through the ffmpeg library and NaPi mechanism integrated in openharmony system?

微创电生理通过注册:年营收1.9亿 微创批量生产上市企业
![[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou
随机推荐
C for循环内定义int i变量出现的重定义问题
Developing NES games with C language (cc65) 09, scrolling
Design a thread pool
Developing NES games with C language (cc65) 06. Sprites
SuperMap iclient3d for webgl to realize floating thermal map
FlexPro软件:生产、研究和开发中的测量数据分析
HC-05蓝牙模块调试从模式和主模式经历
Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held
C structure use
Sub database and sub table may not be suitable for your system. Let's talk about how to choose sub database and sub table and newsql
大模型哪家强?OpenBMB发布BMList给你答案!
Ten prohibitions for men and women in love
与元素类型 “item” 相关联的 “name” 属性值不能包含'<” 字符解决办法
Distributed session solution
Baidu map API adds information window circularly. The window only opens at the last window position and the window information content is the same solution
STM32F103 几个特殊引脚做普通io使用注意事项以及备份寄存器丢失数据问题1,2
[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou
软件架构师必需要了解的 saas 架构设计?
Is it difficult for cloud native machine learning to land? Lingqueyun helps enterprises quickly apply mlops
How does musk lay off staff?