在自动完成文本框中指定字体. [英] Specifying font in AutoComplete TextBox.

查看:88
本文介绍了在自动完成文本框中指定字体.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用以下代码行添加了自动完成功能,但自动完成文本采用默认字体.在这种情况下如何指定另一种字体.向我建议解决这个问题的方法.提前感谢.
-萨蒂扬

I''ve added the feature of autocomplete in my application with following lines of code but the autocomplete text came in the default font. how to specify another font in this scenario. Suggest me the way tackle this problem. Thanx in advance.
-Satyam

public string strConnection = ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ConnectionString.ToString();
AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();

public Form1()
{
    InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
    MySqlDataReader dReader;
    MySqlConnection conn = new MySqlConnection();
    conn.ConnectionString = strConnection;
    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = conn;
    cmd.CommandText = "select name from VDCMunicipalityInfo";
    conn.Open();
    dReader = cmd.ExecuteReader();
    if (dReader.HasRows == true)
    {
        while (dReader.Read())
            namesCollection.Add(dReader["name"].ToString());
    }
    else
    {
        MessageBox.Show("Data not found");
    }
    dReader.Close();
    txtName.AutoCompleteMode = AutoCompleteMode.Suggest;
    txtName.AutoCompleteSource = AutoCompleteSource.CustomSource;
    txtName.AutoCompleteCustomSource = namesCollection;
}

推荐答案

尝试设置属性txtName.Font
Try setting the property txtName.Font


无法完成.操作系统没有公开设置自动完成弹出窗口的字体的方法.您必须滚动自己的自动完成功能才能做到这一点.
This cannot be done. The OS does not expose a method to set the font of the auto complete pop-up. You would have to roll your own auto complete function to do this.


这篇关于在自动完成文本框中指定字体.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆