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. C#如何用IL和Emit类通过Calli来实现实例函数与静态函数的调用

    一. 介绍 最近充能看书,在书上看到函数调用可以 " 通过 ldftn 获得函数指针,然后使用 calli 指令 " 来进行调用,并说这种行为 " 类似 C 的函数指针, ...

  2. Python安装PyOpenGL

    1.目前PyOpenGL是用python2写的,如果你使用的是python3需要自己修改PyOpenGL,我这里使用的是python2.7 2.下载PyOpenGLhttps://pypi.org/p ...

  3. 用 Python 带你看各国 GDP 变迁

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 周萝卜 源自:萝卜大杂烩 PS:如有需要Python学习资料的小伙伴 ...

  4. CAD制图初学入门教程:怎么在CAD中绘制箭头

    在接触CAD的时候大家有没有和小编一样感觉无所适从,所以下面就来和大家分享一个CAD制图初学入门教程,在CAD中绘制箭头.在CAD图形上进行标注内容的时候一般都会使用箭头来进行指示,那具体怎么在CAD ...

  5. 版本管理·玩转git(分支管理)

    在开发中,遇到这样的情况怎么办? 网站已有支付宝在线支付功能,要添加"微信支付",修改了两个文件,wechat.php.pay.php. 刚做到一半,突然有个紧急bug:支付宝支付 ...

  6. 【JavaWeb】FreeMarker快速入门

    FreeMarker Freemarker是免费开源的模板引擎技术: Freemarker脚本为Freemarker Template Language: Freemarker提供了大量内建函数来简化 ...

  7. [转]Oracle 11g RAC SCAN ip的原理及配置

    原文地址:http://tiany.blog.51cto.com/513694/1421917/ Oracle 11g RAC SCAN ip的原理及配置   Oracle 11g RAC网格即插即用 ...

  8. Linux统计文件夹、文件数量的命令

    # 查看当前目录下的文件数量(不包含子目录中的文件) ls -l|grep "^-"| wc -l # 查看当前目录下的文件数量(包含子目录中的文件) 注意:R,代表子目录 ls ...

  9. 使用响应的json数据判断订单查询是否成功;

    #查询中通快递import requestsrr=requests.session()headers={"User-Agent": "Mozilla/5.0 (Windo ...

  10. C++中的C

    前言 因为C++是以C为基础的,所以要用C++编程就必须熟悉C的语法. C语言的学习可以学习K & R C的<C程序设计语言> 创建函数 Q: 函数原型? A: 标准C/C++有一 ...