1取汉字汉语拼音首字母:

private static string GetFirstLetterOfChineseString(string CnChar)
{
long iCnChar;
byte[] ZW = System.Text.Encoding.Default.GetBytes(CnChar);

//如果是字母,则直接返回
if (ZW.Length == 1)
{
return CnChar.ToUpper();
}
else
{
int i1 = (short)(ZW[0]);
int i2 = (short)(ZW[1]);
iCnChar = i1 * 256 + i2;
}
if ((iCnChar >= 45217) && (iCnChar <= 45252))
{
return "A";
}
else if ((iCnChar >= 45253) && (iCnChar <= 45760))
{
return "B";
}
else if ((iCnChar >= 45761) && (iCnChar <= 46317))
{
return "C";
}
else if ((iCnChar >= 46318) && (iCnChar <= 46825))
{
return "D";
}
else if ((iCnChar >= 46826) && (iCnChar <= 47009))
{
return "E";
}
else if ((iCnChar >= 47010) && (iCnChar <= 47296))
{
return "F";
}
else if ((iCnChar >= 47297) && (iCnChar <= 47613))
{
return "G";
}
else if ((iCnChar >= 47614) && (iCnChar <= 48118))
{
return "H";
}
else if ((iCnChar >= 48119) && (iCnChar <= 49061))
{
return "J";
}
else if ((iCnChar >= 49062) && (iCnChar <= 49323))
{
return "K";
}
else if ((iCnChar >= 49324) && (iCnChar <= 49895))
{
return "L";
}
else if ((iCnChar >= 49896) && (iCnChar <= 50370))
{
return "M";
}

else if ((iCnChar >= 50371) && (iCnChar <= 50613))
{
return "N";
}
else if ((iCnChar >= 50614) && (iCnChar <= 50621))
{
return "O";
}
else if ((iCnChar >= 50622) && (iCnChar <= 50905))
{
return "P";
}
else if ((iCnChar >= 50906) && (iCnChar <= 51386))
{
return "Q";
}
else if ((iCnChar >= 51387) && (iCnChar <= 51445))
{
return "R";
}
else if ((iCnChar >= 51446) && (iCnChar <= 52217))
{
return "S";
}
else if ((iCnChar >= 52218) && (iCnChar <= 52697))
{
return "T";
}
else if ((iCnChar >= 52698) && (iCnChar <= 52979))
{
return "W";
}
else if ((iCnChar >= 52980) && (iCnChar <= 53640))
{
return "X";
}
else if ((iCnChar >= 53689) && (iCnChar <= 54480))
{
return "Y";
}
else if ((iCnChar >= 54481) && (iCnChar <= 55289))
{
return "Z";
}
else return ("?");
}

2.ComboBox TextChanged事件  TextBoxBase.TextChanged="Cmb_OnTextChanged"

<ComboBox x:Name="cmb" Grid.Row="0" Grid.Column="0" IsEditable="True" IsTextSearchCaseSensitive="False" IsTextSearchEnabled="True" FontSize="30"    TextBoxBase.TextChanged="Cmb_OnTextChanged">

3. 文字变化,过滤下拉框,下拉框弹出

private void Cmb_OnTextChanged(object sender, TextChangedEventArgs e)
{
filterList = new List<string>();
string str = cmb.Text;
if (string.IsNullOrEmpty(str.Trim()))
{
cmb.ItemsSource = null;
cmb.Items.Clear();
cmb.ItemsSource = list;
cmb.IsDropDownOpen = true;
return;
}

foreach (var l in list)
{
cmb.ItemsSource = null;
cmb.Items.Clear();
if (GetFirstLetterOfChineseString(l).ToLower().Equals(str.Trim()))
{
if (!filterList.Contains(l))
{
filterList.Add(l);
}
}
cmb.ItemsSource = filterList;
cmb.IsDropDownOpen = true;
}
}

WPF,ComboBox,取汉字首字母,extBoxBase.TextChanged的更多相关文章

  1. C#取汉字首字母,汉字全拼

    使用类库为 https://gitee.com/kuiyu/dotnetcodes/tree/master/DotNet.Utilities/%E6%B1%89%E5%AD%97%E8%BD%AC%E ...

  2. java 取汉字首字母

    有时候,可能会有一些类似这样的需求: 对于这样的效果,我们可以有类似这样的解决方案: package bys.utils; import java.io.UnsupportedEncodingExce ...

  3. sql 取汉字首字母

    )) ) --用于加密 --WITH ENCRYPTION as begin declare @intLen int ) ) set @intLen = len(@str) set @strRet = ...

  4. SQL SERVER 得到汉字首字母函数四版全集 --【叶子】

    --创建取汉字首字母函数(第三版) create function [dbo].[f_getpy_V3] ( ) ) ) as begin ),) ,@len = len(@col),@sql = ' ...

  5. php方法-------将汉字转为拼音或者提取汉字首字母

    将汉字转为全拼,提取汉字首字母 <?php /** * 基于PHP语言的汉语转拼音的类 * 兼容 UTF8.GBK.GB2312 编码,无须特殊处理 * 对中文默认返回拼音首字母缩写,其它字符不 ...

  6. MSSQL 获取汉字全拼 和 汉字首字母

    --获取全拼 DECLARE @str VARCHAR(max) SET @str= [dbo].[fn_Getquanpin]('中山') PRINT(@str) )) ) as begin ),) ...

  7. JS获取汉字首字母

    //获取 汉字首字母 function makePy(str) { if (typeof (str) != "string") throw new Error(-1, " ...

  8. ASP.NET获取汉字首字母

    /// <summary> /// 获取汉字首字母(可包含多个汉字) /// </summary> /// <param name="strText" ...

  9. php获取汉字首字母

    php获取汉字首字母,可以用于按字母对数据进行检索排序等. 分享下网上找的代码.亲测有效. function getFirstCharter($str){ if(empty($str)){return ...

随机推荐

  1. GitHub 2019年年度报告:Python最受欢迎,VScode贡献者高达19.1K

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 开源最前线(ID:OpenSourceTop) PS:如有需要Pyt ...

  2. sqlserver 问题来了,视图不会自动更新,如果是用*创建的

    奇葩问题一个 create view时候用的select * 关联了几个表创建的. 后修改select *  的表,结果悲剧了. select * from 视图得到的结果绝对让你想哭.不报错,不提示 ...

  3. 性能优化之mybatis实现接口的批量查询,减少数据库的查询消耗

    <select id="selectByTime" resultType="com.neo.xnol.api.activity.dto.ActivityMqmsgD ...

  4. SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了?

    SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了? 正确答案是: 不允许,这是SAP标准逻辑. 那么问题来了!今日收到业务人员报说采购订单4300013979,完成了收货和IV, ...

  5. 03webpack--输入webpack--自动打包

    如何实现时时跟新我写的代码 此时就需要有一个配置文件了 webpack.config.js这个文件 这个文件是在跟目录下哦 webpack是基于node去构建的 所以你的依法和node还是很相似的哦 ...

  6. C# WF 第12节 Timer控件

    本节内容: 1:Timer控件的简介 2:实例1  : 不停的弹出,恶意exe 3:实例2: :流水灯 4:实例3:给流水灯加上计时器和在规定的时间进行播放音乐 1:Timer控件的简介 2:实例1 ...

  7. Tensorflow之变量赋值输出1+2+3+4+5+6+7+8+...

    一.导入tensorflow import tensorflow as tf 二.定义计算图 (1)常量初始化 constant_name = tf.constant(value) (2)变量初始化 ...

  8. Host '10.133.3.34' is not allowed to connect to this MySQL server mysql 本地拒接连接

    mysql 本地拒接连接 解决方案是,把mysql库中的user表的host 改成% 运行所电脑连接 也可以把第一行复制一遍  把localhost改成你要连接电脑的ip(推荐这改,这样安全一点) 改 ...

  9. day81_10_30redis的简单操作。

    一.启动redis 在启动redis中可以持续的启动redis服务端,启动的服务端即使被关掉也不会停止服务: >: redis-server & 在客户端连接刚刚启动的redis服务端: ...

  10. 剑指Offer-16.合并两个排序的链表(C++/Java)

    题目: 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 分析: 可以用一个新的节点,来去比较两个单调递增的链表当前节点的值,如果p1当前的值小于p2,则新 ...