.net 列表框焦点项目
这是一个问题 在SelectionMode=MultiSimple的列表框中,如何获取当前关注的项目.net 列表框焦点项目,.net,winforms,controls,.net,Winforms,Controls,这是一个问题 在SelectionMode=MultiSimple的列表框中,如何获取当前关注的项目 请注意,我不想获取SelectedItem或SelectedItem,但当前有虚线的项目,类似ListView.FocusedItem。我认为默认情况下没有一个项目-用户控件可能是您在此处的唯一选项 你可能想重新思考你在做什么-为什么你需要聚焦的而不是选择的?这可能有不同的方法。这不是一个完美的解决方案,但一个解决方法可能是在模糊事件触发时将selectedItem存储到一个“focusedIt
请注意,我不想获取SelectedItem或SelectedItem,但当前有虚线的项目,类似ListView.FocusedItem。我认为默认情况下没有一个项目-用户控件可能是您在此处的唯一选项
你可能想重新思考你在做什么-为什么你需要聚焦的而不是选择的?这可能有不同的方法。这不是一个完美的解决方案,但一个解决方法可能是在模糊事件触发时将
selectedItem
存储到一个“focusedItem
”中,然后在需要时简单地检索它。这有点麻烦,但我还没有找到更好的解决方案
if (e.State == DrawItemState.Focus) {
myfocus = e.Index;
}
// Draw the background of the ListBox control for each item.
e.DrawBackground();
// Define the default color of the brush as black.
if (brochas.Count != colores.Count) {
ProcesarBrochas();
}
// Draw the current item text based on the current Font
// and the custom brush settings.
if (Items.Count > e.Index) {
e.Graphics.DrawString(Items[e.Index].ToString(),
e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
}
// If the ListBox has focus, draw a focus rectangle around the selected item.
e.DrawFocusRectangle();
我想要的是,当用户“聚焦”在第一项上并按“向上箭头”键时,将焦点设置在其他控件上。我没有在ListBox控件上找到模糊事件,它在哪里?