当前位置:网站首页>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
边栏推荐
- Did kafaka lose the message
- SuperMap arsurvey license module division
- Merge table rows - three levels of for loop traversal data
- The 'name' attribute value associated with the element type 'item' cannot contain '& lt;' Character solution
- Using Arduino to develop esp8266 to build a development environment
- 用C语言开发NES游戏(CC65)08、背景 碰撞
- 软件架构师必需要了解的 saas 架构设计?
- Localization, low latency, green and low carbon: Alibaba cloud officially launched Fuzhou data center
- 【萌新解题】爬楼梯
- Hc-05 Bluetooth module debugging slave mode and master mode experience
猜你喜欢

Basic use of JSON server

GMT installation and use

Why do enterprises need the ability of enterprise knowledge management?

Newly released, the domestic ide developed by Alibaba is completely open source

OpenAtom OpenHarmony分论坛圆满举办,生态与产业发展迈向新征程

01 pyechars 特性、版本、安装介绍

What SaaS architecture design does a software architect need to know?

MMA8452Q几种模式的初始化实例

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

FlexPro软件:生产、研究和开发中的测量数据分析
随机推荐
微创电生理通过注册:年营收1.9亿 微创批量生产上市企业
界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
GMT installation and use
Analysis of new retail e-commerce o2o model
VS1003 debugging routine
洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东
非标自动化设备企业如何借助ERP系统,做好产品质量管理?
Developing NES games with C language (cc65) 02. What is v-blank?
用C语言开发NES游戏(CC65)08、背景 碰撞
DIY system home page, your personalized needs PRO system to meet!
Let Arduino support nuvotom Xintang
用C语言开发NES游戏(CC65)05、调色板
金山云冲刺港股拟双重主要上市:年营收90亿 为雷军力挺项目
Brief discussion on open source OS distribution
合并表格行---三层for循环遍历数据
Kafaka丢消息吗
[nuxt 3] (XII) project directory structure 3
Distributed session solution
新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
Uniapp wechat applet realizes the function of connecting low-power Bluetooth printing