首页 \ 问答 \ 可以在第二次覆盖自定义控制调用的onleave吗?(it is possiable to override onleave of custom contol call to second time?)

可以在第二次覆盖自定义控制调用的onleave吗?(it is possiable to override onleave of custom contol call to second time?)

首先,我们需要覆盖一个自定义控件,使文本框文本Titlecase在该CaseingTxtBox离开时,第二次我们在表单中使用该离开事件来调用某个方法。 这可能吗?

我们尝试了下面的代码,但我们每次都会调用CaseingTxtBoxOnleave事件,但是没有调用firstNameTextBox_Leave()

我创建了一个自定义控件,为我的文本框添加了正确的大小写,并继承自TextBox ,我们使用文本框的Leave事件来创建自定义文本框的文本标题大小写。

public class CaseingTxtBox : TextBox
{  
    protected override void OnLeave(EventArgs e)
    {
        Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Text.ToLower());
        //first call this event for make text titlecase
    }
}

我们在我的表单中使用了CaseingTxtBox控件来使文本正确,并且效果非常好。 我们还使用该控件的Leave事件来调用方法,但不调用该方法。

this.firstNameTextBox.Leave += new System.EventHandl(this.firstNameTextBox_Leave);

 private void firstNameTextBox_Leave(object sender, EventArgs e)
{
    MessageBox.Show("hello");
    //second time call this event for call some method or propmt   messagebox onleave of CaseingTxtBox .
}

First we need to override a custom control to make textbox text Titlecase on leave of that CaseingTxtBox and second time we use that leave event in a form to call some method. Is this possible?

We tried the code below for that but we get a call every time for CaseingTxtBox's Onleave event but no call for firstNameTextBox_Leave()

I made a custom control that doed proper case for my textbox and that inherits from TextBox and we use the Leave event of the textbox to make the custom textbox's text title case.

public class CaseingTxtBox : TextBox
{  
    protected override void OnLeave(EventArgs e)
    {
        Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Text.ToLower());
        //first call this event for make text titlecase
    }
}

We use that CaseingTxtBox control in my form to make text proper case and that works very well. We also use Leave event of that control to call a method but that method is not called.

this.firstNameTextBox.Leave += new System.EventHandl(this.firstNameTextBox_Leave);

 private void firstNameTextBox_Leave(object sender, EventArgs e)
{
    MessageBox.Show("hello");
    //second time call this event for call some method or propmt   messagebox onleave of CaseingTxtBox .
}

原文:https://stackoverflow.com/questions/32667600
更新时间:2024-01-18 10:01

最满意答案

试试这个。

var arr = ['top','dir1','dir2','dir3'];

for(var i=0,j=arr.length;i<j;i++)
{
   arr[i] = i  > 0 ? arr[i-1] + '/' + arr[i] : '#'+arr[i];
}

alert(arr.join(','))

Try this.

var arr = ['top','dir1','dir2','dir3'];

for(var i=0,j=arr.length;i<j;i++)
{
   arr[i] = i  > 0 ? arr[i-1] + '/' + arr[i] : '#'+arr[i];
}

alert(arr.join(','))

相关问答

更多
'; } $co ...
  • 这段代码有几个问题。 最直接的一个是你在array上调用substring而不是string 。 return count(sample.substring ... 可能你想说 return count(sample[i].substring ... 第二个问题是你需要将逻辑分开一点。 您需要将其划分为计算单词中出现次数和迭代数组的部分。 今天它们交织在一起并导致奇怪的行为,因为你最终将非数组传递给期望数组的地方 function count(sample, searchTerm) { var nu ...
  • 我已经为我的问题找到了解决方案。 现在,该片段仅显示团队博客中的文章。 {% for blog in shop.blogs %} {% if blog.title == 'team' %} {% for article in blog.articles | limit(3) %}

    {{ article.title }}

  • each_with_index的语法如下所示: @something.each_with_index do |thing,index| puts index, thing end 然后,您应该更换该行emails.each_with_index do | index | 同 emails.each_with_index do |email,index| 但是,我没有看到你实际使用索引,所以你可以probalby简化为: emails.each do |email| email.attac ...
  • 好吧,多亏了SwiftyJSON,您可以轻松获得这样的价值: let firstId = json["urls"][0]["id"].stringValue 您没有提到要保存值的位置,但您可以简单地使用UserDefaults。 例如: UserDefaults.standard.set(firstId, forKey: "your_key_for_accessing_the_value") 另外,我建议你检查值是否为空: let firstId = json["urls"][0]["id"].stri ...
  • 对于轻量级方法,您可以将组合框名称放在以逗号分隔的字符串中,将字符串Split()放入数组中,然后循环遍历数组成员。 Const cstrNames As String = "cbo1,cbo4,cbo7" Dim varName As Variant For Each varName In Split(cstrNames, ",") Me.Controls(varName).Requery Next 如果要在表单中的其他过程之间共享该列表,可以将字符串设置为模块级常量,而不是在每个过程中再次声 ...
  • 检查names.ToString()返回的内容,不应该对它运行正则表达式。 要获取与您的模式匹配的DefinedNames的数量,您可以使用: names.Count(n => Regex.IsMatch(n.InnerText, @"(?
  • 相关文章

    更多
  • Solr: a custom Search RequestHandler
  • Hadoop源码分析之二(RPC机制之Call处理)
  • Custom SOLR Search Components - 2 Dev Tricks
  • Real-Time Rendering 笔记 --- 1-4章
  • Java 重写(Override)与重载(Overload)
  • My W3C Custom Mapping File
  • Hadoop0.20+ custom MultipleOutputFormat
  • The Log: What every software engineer should know about real-time data's unifying abstraction
  • 自定义埋点函数-Oceanus编码调用
  • RFC2848--The PINT Service Protocol: Extensions to SIP and SDP for IP Access to Telephone Call Services
  • 最新问答

    更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。