2023年7月9日发(作者:)
实现百度搜索框功能实现效果:
基本的实现思路是 界⾯为TextBox(提供关键字的输⼊)+ListBox(相关内容以列表显⽰),数据的获取通过委托实现。 以下是控件实现代码:View Codeusing System;using c;using entModel;using g;using ;using ;using ;namespace MyControl{ ///
/// 必需的设计器变量。 /// private iner components = null; ///
/// 清理所有正在使⽤的资源。 /// /// 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) { if (disposing && (components != null)) { e(); } e(disposing); } #region 组件设计器⽣成的代码 ///
/// 设计器⽀持所需的⽅法 - 不要 /// 使⽤代码编辑器修改此⽅法的内容。 /// private void InitializeComponent() { _context = new x(); dLayout(); //
// tx_context //
_ = ; _on = new (0, 0); _ = new g(0); _ = "tx_context"; _ = new (150, 21); _ex = 0; _anged += new andler(_context_TextChanged); _n += new ntHandler(_context_KeyDown); //
// UC_QueryBox //
aleDimensions = new (6F, 12F); aleMode = ; ze = true; lor = arent; oundImageLayout = h; (_context); Buffered = true; = new g(0); = "UC_QueryBox"; = new (150, 22); += new andler(ox_Load); Layout(false); mLayout(); } #endregion private x tx_context; }}以下是测试项⽬代码:View Codeusing System;using c;using entModel;using ;using g;using ;using ;namespace Test{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //绑定委托 uC_a = new _elegate(GetData); } private List
{ //这⾥写具体的数据获取⽅法 return new List
// uC_QueryBox1 //
_ze = true; _lor = arent; _oundImageLayout = h; _on = new (64, 77); _QueryBox1.M_ListBox = null; _QueryBox1.M_QueryText = ""; _ = new g(0); _ = "uC_QueryBox1"; _ = new (150, 22); _ex = 0; //
// Form1 //
aleDimensions = new (6F, 12F); aleMode = ; Size = new (292, 266); (_QueryBox1); = "Form1"; = "Form1"; += new andler(1_Load); Layout(false); mLayout(); } #endregion private _QueryBox uC_QueryBox1; }}以上代码的不⾜之处是,当此控件在容器边缘时下拉框显⽰不全,如设置容器AutoSize为True效果也不理想。
发布者:admin,转转请注明出处:http://www.yc00.com/news/1688892352a181719.html
评论列表(0条)