c#标签“ hitbox”-空白记为标签,标签短

时间:2018-08-26 13:24:46

标签: c# label

有我的密码

        private void button1_Click(object sender, EventArgs e)
    {
        games += 1;
        LocPoint += 1;
        Label label = new Label
        {

            Name = "game_" + games,
            Text = "New Game",
            Cursor = Cursors.Hand,
            Location = new Point(25, LocPoint * 24)
        };
        Controls.Add(label);
        label.Click += Label_Click;

我得到了enter image description here

但是正如您所看到的,光标部分不在标签文本中。 及其最多16个字符://

1 个答案:

答案 0 :(得分:0)

如果未设置为任何其他值,则标签属性“高度”设置为23,“宽度”设置为100。 将它们设置为默认的其他值或尝试以下操作:

from flashtext import KeywordProcessor

keywords = ['Yosemite',
            'Yosemite National Park',
            'Yosemite Valley',
            'Yosemite National Park Lodge',
            'Yosemite National Park Visitor Center',
            'San Francisco',
            'Golden Gate Park San Francisco',
            'Paris',
            'New York',
            'Manhattan New York',
            'Hong Kong']

keyword_processor = KeywordProcessor(case_sensitive=False)
for keyword in keywords:
    keyword_processor.add_keyword(keyword)

sentences = ["I proposed to my wife on the 12th of November 1984, during a crazy downpour in the middle of Yosemite in California",
"I love to walk my dog in Central Park, New York",
"I love Hong Kong"]

for sentence in sentences:
    extracted = keyword_processor.extract_keywords(sentence)
    print(extracted)

AutoSize会根据文本的大小将“高度”和“宽度”的值设置为最小大小。