SimpleWindow
载入中...
搜索中...
未找到
ComboBox.h
1#pragma once
2
3#include "ItemsControl.h"
4#include "ObservableCollection.h"
5
6namespace sw
7{
11 class ComboBox : public ItemsControl
12 {
13 private:
17 using TBase = ItemsControl;
18
22 bool _isTextChanged = false;
23
28
29 public:
34
39
40 public:
45
49 void Refresh();
50
55
60
61 protected:
68
75
81
86
91
97
103
108
114 virtual std::wstring GetDisplayText(int index, const Variant &item);
115
116 private:
120 void _UpdateSelectedText();
121
125 void _UpdateItems();
126
131 void _AddString(const std::wstring &str);
132
138 void _InsertString(int index, const std::wstring &str);
139
144 void _DeleteString(int index);
145 };
146}
组合框
Definition ComboBox.h:12
virtual void SetSelectedIndex(int index) override
设置选中项索引
virtual int GetSelectedIndex() override
选中项的索引,当无选中项时为-1
void Refresh()
刷新控件以反映数据源的当前状态
void CloseDropDown()
关闭下拉列表
void ShowDropDown()
显示下拉列表
virtual void OnCurrentItemsSourceCollectionChanged(const NotifyCollectionChangedEventArgs &args) override
当数据源集合发生变更时调用该函数
virtual void OnCommand(int code) override
当父窗口接收到控件的WM_COMMAND时调用该函数
virtual IList * GetDefaultItemsSource() override final
获取默认数据源,当ItemsSource未设置时使用该数据源
virtual void OnCurrentItemsSourceChanged(IList *oldItemsSource, IList *newItemsSource) override
当前数据源改变时调用该函数
const Property< bool > IsEditable
组合框内容是否可编辑
Definition ComboBox.h:38
virtual void OnSelectionChanged() override
选中项改变时调用该函数
ComboBox()
初始化组合框
const ReadOnlyProperty< ObservableCollection< std::wstring > * > Items
列表框的子项集合,当未设置ItemsSource时使用该集合作为数据源
Definition ComboBox.h:33
virtual std::wstring GetDisplayText(int index, const Variant &item)
获取子项要显示的文本
virtual std::wstring & GetInternalText() override
获取窗口文本
非模板列表接口,提供基于Variant的元素访问
Definition IList.h:11
值转换器接口
Definition IValueConverter.h:14
表示可用于呈现一组项的控件
Definition ItemsControl.h:13
ItemsControl()
构造函数
集合变更事件参数类型
Definition INotifyCollectionChanged.h:33
通用变体类型容器,类型擦除地持有任意类型对象
Definition Variant.h:36
SimpleWindow框架的顶级命名空间,所有公共类型、控件、枚举和工具函数均定义于此。
Definition Alignment.h:4