Scenario : I am working on project where my client needs to open the drop down(combo items) of combo box on f1 key down , but i am achieving it my try multiple codes. how can i open combo box items on any key event. Here is my code
private void dgvItemLists_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Subtract)
{
txtDiscount.Focus();
}
if (e.KeyCode == Keys.Add)
{
mtxtQty.Focus();
}
if (e.KeyCode == Keys.F1)
{
cmbAreaName.Focus();
// cmbAreaName.AllowDrop = true;
// cmbAreaName.Show();
cmbAreaName_Click(this, new System.EventArgs());
//cmbAreaName_DrawItem(this, new DrawItemEventArgs);
// cmbAreaName.SelectedIndexChanged=;
}
}
required result image is given.
any suggestions or recommendations of code will be highly appreciated.
Currently, you're just executing the code inside the Click
event when you call cmbAreaName_Click
.
If you want to show the dropdown, set the DroppedDown
property to true
:
cmbAreaName.DroppedDown = true;
Try
if (e.KeyCode == Keys.F1)
{
cmbAreaName.DroppedDown = true;
}
Maybe you should put this in a method so you can raise it on events you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.