如何填充我的DataGridViewComboboxColumn? [英] how do I populate my DataGridViewComboboxColumn?

查看:169
本文介绍了如何填充我的DataGridViewComboboxColumn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用属性添加了项目,在运行时,下拉列表中没有项目。

I added items using Properties and at runtime, the dropdown had no items there.

我有点困惑,会非常感谢任何帮助。

I am a little confused and would really appreciate any help.

我也没有看到一种方式为我分配一个事件处理程序

I also didnt see a way for me to assign an Event Handler to the Combobox.

推荐答案

使用 combobox.Items.Add()要将项目添加到组合框中,则可以使用 combobox.SelectedIndex

use combobox.Items.Add() to add items to the combo box, then you can set the default selection using combobox.SelectedIndex

更多信息设置默认选择: https://msdn.microsoft.com/en- us / library / aa983551(v = vs.71).aspx

more info: https://msdn.microsoft.com/en-us/library/aa983551(v=vs.71).aspx

示例:

foreach (string s in SerialPort.GetPortNames())
{
    comboMachinePort.Items.Add(s);
}
comboMachinePort.SelectedIndex = 0;

这篇关于如何填充我的DataGridViewComboboxColumn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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