自定义ComboBox,简简单单实现

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Popup1.PlacementTarget = TesTextBox;
            Popup1.Placement = PlacementMode.Bottom;
            Popup1.IsOpen = true;
        }

        private void TestDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TesTextBox.Text = (dataGrid.SelectedItem as DataRowView).Row["c_AirStrategyExpCode"].ToString();
        }
            dataGrid.ItemsSource = ds.Tables[0].DefaultView;
            dataGrid.LoadingRow += DataGridOnLoadingRow;
                <StackPanel Orientation="Horizontal" Height="40">
                    <TextBlock  Text="ComboBox:" Height="18" Width="70" />
                    <Border Height="22" BorderBrush="DarkGray" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock x:Name="TesTextBox" Height="20" Width="154"/>
                            <Button Height="20" Width="14" Click="Button_Click" Style="{StaticResource FrameBtnStyle4}">
                                <Popup x:Name="Popup1" Height="300" StaysOpen="False">
                                    <Border BorderBrush="DarkGray"  BorderThickness="1">
                                        <DataGrid x:Name="dataGrid" GridLinesVisibility = "None" CanUserReorderColumns = "false"
                                                  Style="{StaticResource DataGridStyle1}" RowStyle="{StaticResource DataGridRowStyle1}"
                                                  CellStyle="{StaticResource DataGridCellStyle1}" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle1}"
                                                  IsReadOnly="True" SelectionChanged="TestDataGrid_SelectionChanged"/>
                                    </Border>
                                </Popup>
                            </Button>
                        </StackPanel>
                    </Border>
                </StackPanel>

自定义ComboBox,简简单单实现

时间: 2024-08-08 04:48:26

自定义ComboBox,简简单单实现的相关文章

自定义ComboBox控件,完美解决C#自带的ComboBox效率慢的问题

自定义ComboBox控件,完美解决C#自带的ComboBox效率慢的问题 欢迎关注http://blog.csdn.net/aaa123524457 转载请注明出处:http://blog.csdn.net/aaa123524457/article/details/47058675 在做项目的时候,用到了ComboBox来做下拉列表的功能:但是在用的时候发现C#自带的ComboBox效率非常的慢! 当然我添加的是股票.期货的合约数据,大概有几千条信息,算是比较大的.如果用到的数据很少,就可以直

Flex4.6 DataGrid自定义ComboBox并获取自定义ComboBox的值

最近,项目需求需要在DataGrid上动态生成GridColumn以及设置其为ComboBox,默认是为TextInput. Flex 4.6使用s:DataGrid组件而不是mx:DataGrid,网上很多资料都是mx组件的,于是写了这篇文章. 首先,s:DataGrid的标题栏存储的对象是GridColumn. 标题栏动态添加函数 <span style="font-family:Microsoft YaHei;font-size:18px;"> var columns

WPF的ComboBox 数据模板自定义

WPF的ComboBox 有些时候不能满足用户需求,需要对数据内容和样式进行自定义,下面就简要介绍一下用数据模板(DataTemplate)的方式对ComboBox 内容进行定制: 原型设计如下: 步骤: 1.新建一个WPF应用程序WpfAppDemo(VS2012),并新建一个images文件夹(上传图片素材); 2.在主界面MainWindow.xaml文件中添加一个Label.ComboBox 和Button控件,如下图: 代码如下: 1 <Window x:Class="WpfAp

自定义窗体,简简单单实现

style文件xmal: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <ControlTemplate x:Key="WindowTemplateKey" TargetType="

ComboBox列表自定义类保存数据

之前没弄明白ComboBox还可以这样用. 先建一个ComboBox子项类,然后可以获取该项类做一些判断,关键是要重写ToString()方法. public class ComboItem { public string text; public string value; public override string ToString() { return text; } } 添加到ComboBox中: private void Form1_Load(object sender, Event

Combobox值自定义(不通过数据库)

前台 <ext:ComboBox ID="cmbYear" runat="server"/> .aspx.cs int year = DateTime.Now.Year + 4; while (year >= 2012) { cmbYear.Items.Add(new Coolite.Ext.Web.ListItem(year, year.ToString())); year--; } 原文地址:https://www.cnblogs.com/wu

c#(winform)中自定义ListItem类方便ComboBox添加Item项

1.定义ListItem类 public class ListItem { private string _key = string.Empty; private string _value = string.Empty; public ListItem(string pKey, string pValue) { _key = pKey; _value = pValue; } public override string ToString() { return this._value; } pu

combobox和combotree模糊查询

First /** * combobox和combotree模糊查询 * combotree 结果显示两级父节点(手动设置数量) * 键盘上下键选择叶子节点 * 键盘回车键设置文本的值 */ (function(){ //combobox可编辑,自定义模糊查询 $.fn.combobox.defaults.editable = true; $.fn.combobox.defaults.filter = function(q, row){ var opts = $(this).combobox('

combobox 属性、事件、方法

一 .combobox 属性.事件.方法公共属性 名称 说明 AccessibilityObject 获取分配给该控件的 AccessibleObject. AccessibleDefaultActionDescription 获取或设置控件的默认操作说明,供辅助功能客户端应用程序使用. AccessibleDescription 获取或设置辅助功能客户端应用程序使用的控件说明. AccessibleName 获取或设置辅助功能客户端应用程序所使用的控件名称. AccessibleRole 获取