有个表保存了地名(汉字)等信息,现在我想在combox输入框中输入地名的第一个字母(或第一和第二个字母)的时候能把首字母含有此字母的地名列出来。
例如:输入"S"能把“山东”、“山西”、“汕头”等列出来。
看了网上一些例子,但总不够理想,希望各位能给个例子。

解决方案 »

  1.   

    function CharToShort( // 得到汉字的拼音简码
      AChar: WideChar // 单个汉字
    ): Char; // 返回单个汉字的拼音简码
    begin
      if (AChar >= '啊') and (AChar <= '澳') then
        Result := 'A'
      else if (AChar >= '芭') and (AChar <= '怖') then
        Result := 'B'
      else if (AChar >= '擦') and (AChar <= '搭') then
        Result := 'C'
      else if (AChar >= '达') and (AChar <= '堕') then
        Result := 'D'
      else if (AChar >= '蛾') and (AChar <= '贰') then
        Result := 'E'
      else if (AChar >= '发') and (AChar <= '咐') then
        Result := 'F'
      else if (AChar >= '噶') and (AChar <= '过') then
        Result := 'G'
      else if (AChar >= '哈') and (AChar <= '祸') then
        Result := 'H'
      else if (AChar >= '击') and (AChar <= '骏') then
        Result := 'J'
      else if (AChar >= '喀') and (AChar <= '阔') then
        Result := 'K'
      else if (AChar >= '垃') and (AChar <= '络') then
        Result := 'L'
      else if (AChar >= '妈') and (AChar <= '穆') then
        Result := 'M'
      else if (AChar >= '拿') and (AChar <= '诺') then
        Result := 'N'
      else if (AChar >= '哦') and (AChar <= '沤') then
        Result := 'O'
      else if (AChar >= '啪') and (AChar <= '瀑') then
        Result := 'P'
      else if (AChar >= '期') and (AChar <= '群') then
        Result := 'Q'
      else if (AChar >= '然') and (AChar <= '弱') then
        Result := 'R'
      else if (AChar >= '撒') and (AChar <= '所') then
        Result := 'S'
      else if (AChar >= '塌') and (AChar <= '唾') then
        Result := 'T'
      else if (AChar >= '挖') and (AChar <= '误') then
        Result := 'W'
      else if (AChar >= '牺') and (AChar <= '迅') then
        Result := 'X'
      else if (AChar >= '压') and (AChar <= '孕') then
        Result := 'Y'
      else if (AChar >= '匝') and (AChar <= '座') then
        Result := 'Y'
      else Result := '_';
    end; { CharToShort }function StringToShort( // 得到字符串的拼音简码
      AString: WideString // 字符串
    ): string; // 返回拼音简码,如果是字母则不改变
    var
      I: Integer;
    begin
      Result := '';
      for I := 1 to Length(AString) do
        if AString[I] > #255 then
          Result := Result + CharToShort(AString[I])
        else Result := Result + UpperCase(AString[I]);
    end; { StringToShort }
      

  2.   

    我有一个第三方控件!~
    如果你没事的话可以给我发邮件
    我给你传过去!~
    [email protected]
      

  3.   

    这样吧,没有那么麻烦咯,在www.delphifans.com上有一个源程序可以使用.查查吧,如果需要可以发到邮箱里吧.
      

  4.   

    楼上,能否将你说的源码发到我邮箱。[email protected],谢谢