gpt4 book ai didi

c# - 自动完成导致文本向右滚动

转载 作者:行者123 更新时间:2023-11-30 21:48:11 25 4
gpt4 key购买 nike

我的可编辑 combobox 上的自动完成功能适用于较短的项目。

但是,如果所选字符串太宽且无法放入 combobox,它会向右水平滚动,这可能是自动完成功能选择了字符串的剩余部分的结果。

这会隐藏用户输入点的当前位置。

如何让它保持插入符的位置对用户可见?

<ComboBox x:Name="comboBoxCustomer"
ItemsSource="{Binding Source={StaticResource customerViewSource}}"
TextSearch.TextPath="CustomerDisplay"
SelectedValue="{Binding CustomerID, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
SelectedValuePath="ID"
SelectionChanged="comboBoxCustomer_SelectionChanged"
StaysOpenOnEdit="True"
IsEditable="True" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding CustomerDisplay}" Foreground="{Binding ActiveColour}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

最佳答案

comboboxtextbox 上使用 ScrollToHome 方法。

   private void comboBoxCustomer_KeyUp(object sender, KeyEventArgs e)
{
TextBox tb = (TextBox)comboBoxCustomer.Template.FindName("PART_EditableTextBox", comboBoxCustomer);
tb.ScrollToHome();
}

关于c# - 自动完成导致文本向右滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37856744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com