C#组合框 [英] C# combobox

查看:144
本文介绍了C#组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个带有以下项目的组合框:

年份
月.
我如何在列表视图中添加组合框的内容,但是当在列表视图中插入每个项目时必须具有:
1
2
3
例如,对于Combobox-Day,在列表视图中,我将具有:0?

我试过了:
cb_cond.Items.Insert(0,"Day");
ListViewItem itm =新的ListViewItem(cb_den.Text);
但这不起作用.

解决方案

从哪里开始?

首先,如果您能弄清自己的要求.如果组合框选择为天",是否要让ListView显示所有可能的天数(1-31)?

还是您想要类似的东西
ComboBox ListView
第0天
第1个月
2年级

使用您的代码... cb_cond.Items.Insert(0,"Day")只需将索引为0的项目"Day"添加到列表中即可.它不等于Day等于0.它也不等于"不能更改comboBox中显示的内容.

以及如何更改cb_cond会更改cb_den中的任何内容?因为除非您为要添加到组合框并更新cb_den的项目设置事件处理程序,否则cb_den中的任何内容都不会基于cb_cond进行更改.

我认为您需要从头开始.

你想做什么?您的控件代表什么?这些控件应该是什么?这些控件应如何影响其他控件?就目前情况而言,您仍然没有给我们足够的信息来回答您的问题.

另外,仅创建一个新的ListViewItem并不会自动将其添加到ListView中.您仍然需要执行ListView1.Items.Add(itm).


我有一个组合框和一个列表视图.
组合框项目:

年份

当我添加Day时,必须在列表视图的相应字段中分配1.

Hello,

I have a combobox, with this items :
Day
Year
Month.
How i can add the content of the combobox in a listview, but when a insert in the listview for each item to have:
1
2
3
For example, for Combobox - Day, in listview i will have: 0?

I tried this:
cb_cond.Items.Insert(0,"Day");
ListViewItem itm = new ListViewItem(cb_den.Text);
But it doesn`t work.

解决方案

where to start?

First, if you could clear up what you''re asking for. Are you wanting the ListView to show all of the possible day numbers (1-31) if the combobox selection is Day?

Or are you wanting something like
ComboBox ListView
Day 0
Month 1
Year 2

With your code...cb_cond.Items.Insert(0,"Day") simply adds an item of "Day" to the list with an index of 0. It doesn''t equate Day with 0. It also doesn''t change what is being displayed in the comboBox.

And how does changing cb_cond change anything within cb_den? because unless you''ve set up event handlers for an item being added to a combobox and updating cb_den, then nothing in cb_den will be changed based on cb_cond.

I think you need to start at the beginning.

What are you trying to do? What do your controls represent? What should be in those controls? How should those controls affect other controls? As it stands right now, you still haven''t given us enough information to answer your question.

Also, just creating a new ListViewItem doesn''t automatically add it to a ListView. You still would need to do ListView1.Items.Add(itm).


I have a combobox and a listview.
Combobox items :
Day
Year
Month
When i add Day, in the listview 1 must be assigned in the corresponding field of the listview.


这篇关于C#组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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