DevExpress中的DropDownEdit怎么绑定数据源?
4个回答
展开全部
//绑定lookUpEdit
private void BoundData()
{
string sql = "select daID,xm,sfzh from baseinfo";
DataSet ds = Archives.DataAccess.DataSql.Query(sql);
if (ds != null)
{
int rows = ds.Tables[0].Rows.Count;
lookUpEdit1.EditValue = "daID";
lookUpEdit1.Properties.ValueMember = "daID";
lookUpEdit1.Properties.DisplayMember = "xm";
lookUpEdit1.Properties.DataSource = ds.Tables[0];
//自适应宽度
//lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//填充列
lookUpEdit1.Properties.PopulateColumns();
//设置列属性
//lookUpEdit1.Properties.Columns[0].Visible = false;
lookUpEdit1.Properties.Columns[1].Caption = "姓名";
lookUpEdit1.Properties.Columns[2].Caption = "身份证号";
lookUpEdit1.Properties.Columns[1].Width = 120;
lookUpEdit1.Properties.Columns[2].Width = 300;
//控制选择项的总宽度
lookUpEdit1.Properties.PopupWidth = 500;
//列格式设置
lookUpEdit1.Properties.Columns[0].FormatString = "000000";
//选择第一项
lookUpEdit1.ItemIndex = 0;
}
}
//值改变事件
private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
string daID = this.lookUpEdit1.EditValue.ToString(); //是ookUpEdit.Properties.ValueMember的值
string xm = this.lookUpEdit1.Text.Trim();
}
private void BoundData()
{
string sql = "select daID,xm,sfzh from baseinfo";
DataSet ds = Archives.DataAccess.DataSql.Query(sql);
if (ds != null)
{
int rows = ds.Tables[0].Rows.Count;
lookUpEdit1.EditValue = "daID";
lookUpEdit1.Properties.ValueMember = "daID";
lookUpEdit1.Properties.DisplayMember = "xm";
lookUpEdit1.Properties.DataSource = ds.Tables[0];
//自适应宽度
//lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
//填充列
lookUpEdit1.Properties.PopulateColumns();
//设置列属性
//lookUpEdit1.Properties.Columns[0].Visible = false;
lookUpEdit1.Properties.Columns[1].Caption = "姓名";
lookUpEdit1.Properties.Columns[2].Caption = "身份证号";
lookUpEdit1.Properties.Columns[1].Width = 120;
lookUpEdit1.Properties.Columns[2].Width = 300;
//控制选择项的总宽度
lookUpEdit1.Properties.PopupWidth = 500;
//列格式设置
lookUpEdit1.Properties.Columns[0].FormatString = "000000";
//选择第一项
lookUpEdit1.ItemIndex = 0;
}
}
//值改变事件
private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
string daID = this.lookUpEdit1.EditValue.ToString(); //是ookUpEdit.Properties.ValueMember的值
string xm = this.lookUpEdit1.Text.Trim();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该和平常的dropdownList差不多的吧,你试试。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<dx:ASPxDropDownEdit ClientInstanceName="xDropDownEditAppCountry" ID="xDropDownEditAppCountry"
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxAppCountry" ClientInstanceName="checkListBoxAppCountry"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxAppCountrySelectionChanged" />
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxAppCountryValues" DropDown="SynchronizeListBoxAppCountryValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ClientInstanceName="xDropDownEditFileLevel" ID="xDropDownEditFileLevel"
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxFileLevel" ClientInstanceName="checkListBoxFileLevel"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxFileLevelSelectionChanged" />
<Items>
<dx:ListEditItem Text="全选" Value="9" />
<dx:ListEditItem Text="核心" Value="核心" />
<dx:ListEditItem Text="重要" Value="重要" />
<dx:ListEditItem Text="普通" Value="普通" />
<dx:ListEditItem Text="不重要" Value="不重要" />
</Items>
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxFileLevelValues" DropDown="SynchronizeListBoxFileLevelValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ClientInstanceName="xDropDownEditAppCountry" ID="xDropDownEditAppCountry"
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxAppCountry" ClientInstanceName="checkListBoxAppCountry"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxAppCountrySelectionChanged" />
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxAppCountryValues" DropDown="SynchronizeListBoxAppCountryValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ID="DropDownEdit" runat="server" ClientInstanceName="DropDownEdit"
Width="170px" AllowUserInput="False" EnableAnimation="False">
<DropDownWindowStyle>
<Border BorderWidth="0px" />
</DropDownWindowStyle>
<DropDownWindowTemplate>
<dx:ASPxTreeList ID="TreeList" runat="server" AutoGenerateColumns="False" ClientInstanceName="TreeList"
OnCustomJSProperties="TreeList_CustomJSProperties" OnDataBound="TreeList_DataBound"
KeyFieldName="n_KeyID" OnInit="TreeList_OnInit" ParentFieldName="n_ParentKeyID">
<Border BorderStyle="Solid" />
<SettingsEditing ConfirmDelete="true" />
<SettingsPager Mode="ShowAllNodes" />
<SettingsSelection Enabled="true" Recursive="true" />
<Columns>
<dx:TreeListTextColumn FieldName="n_KeyID" Width="50px" Caption="" Visible="False"
VisibleIndex="0">
</dx:TreeListTextColumn>
<dx:TreeListTextColumn FieldName="s_CName" Caption="机构名称" Width="150px" VisibleIndex="1">
</dx:TreeListTextColumn>
<dx:TreeListTextColumn FieldName="n_ParentKeyID" Width="50px" Visible="False" VisibleIndex="2">
</dx:TreeListTextColumn>
</Columns>
<ClientSideEvents Init="TreeListInitHandler" EndCallback="TreeListEndCallbackHandler"
NodeClick="TreeListNodeClickHandler" SelectionChanged="setSelectValue" FocusedNodeChanged="setSelectValue" />
</dx:ASPxTreeList>
</DropDownWindowTemplate>
</dx:ASPxDropDownEdit>
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxAppCountry" ClientInstanceName="checkListBoxAppCountry"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxAppCountrySelectionChanged" />
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxAppCountryValues" DropDown="SynchronizeListBoxAppCountryValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ClientInstanceName="xDropDownEditFileLevel" ID="xDropDownEditFileLevel"
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxFileLevel" ClientInstanceName="checkListBoxFileLevel"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxFileLevelSelectionChanged" />
<Items>
<dx:ListEditItem Text="全选" Value="9" />
<dx:ListEditItem Text="核心" Value="核心" />
<dx:ListEditItem Text="重要" Value="重要" />
<dx:ListEditItem Text="普通" Value="普通" />
<dx:ListEditItem Text="不重要" Value="不重要" />
</Items>
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxFileLevelValues" DropDown="SynchronizeListBoxFileLevelValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ClientInstanceName="xDropDownEditAppCountry" ID="xDropDownEditAppCountry"
SkinID="CheckComboBox" Width="180px" runat="server" EnableAnimation="False">
<DropDownWindowTemplate>
<dx:ASPxListBox Width="100%" ID="listBoxAppCountry" ClientInstanceName="checkListBoxAppCountry"
SelectionMode="CheckColumn" runat="server" SkinID="CheckComboBoxListBox">
<ClientSideEvents SelectedIndexChanged="OnListBoxAppCountrySelectionChanged" />
</dx:ASPxListBox>
</DropDownWindowTemplate>
<ClientSideEvents TextChanged="SynchronizeListBoxAppCountryValues" DropDown="SynchronizeListBoxAppCountryValues" />
</dx:ASPxDropDownEdit>
<dx:ASPxDropDownEdit ID="DropDownEdit" runat="server" ClientInstanceName="DropDownEdit"
Width="170px" AllowUserInput="False" EnableAnimation="False">
<DropDownWindowStyle>
<Border BorderWidth="0px" />
</DropDownWindowStyle>
<DropDownWindowTemplate>
<dx:ASPxTreeList ID="TreeList" runat="server" AutoGenerateColumns="False" ClientInstanceName="TreeList"
OnCustomJSProperties="TreeList_CustomJSProperties" OnDataBound="TreeList_DataBound"
KeyFieldName="n_KeyID" OnInit="TreeList_OnInit" ParentFieldName="n_ParentKeyID">
<Border BorderStyle="Solid" />
<SettingsEditing ConfirmDelete="true" />
<SettingsPager Mode="ShowAllNodes" />
<SettingsSelection Enabled="true" Recursive="true" />
<Columns>
<dx:TreeListTextColumn FieldName="n_KeyID" Width="50px" Caption="" Visible="False"
VisibleIndex="0">
</dx:TreeListTextColumn>
<dx:TreeListTextColumn FieldName="s_CName" Caption="机构名称" Width="150px" VisibleIndex="1">
</dx:TreeListTextColumn>
<dx:TreeListTextColumn FieldName="n_ParentKeyID" Width="50px" Visible="False" VisibleIndex="2">
</dx:TreeListTextColumn>
</Columns>
<ClientSideEvents Init="TreeListInitHandler" EndCallback="TreeListEndCallbackHandler"
NodeClick="TreeListNodeClickHandler" SelectionChanged="setSelectValue" FocusedNodeChanged="setSelectValue" />
</dx:ASPxTreeList>
</DropDownWindowTemplate>
</dx:ASPxDropDownEdit>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2017-09-13
展开全部
this.treeList.DataSource = dt;
this.treeList.ParentFieldName = "Father_City_Id";
this.treeList.KeyFieldName = "CityId";
差不多就是这样
另外,团IDC网上有许多产品团购,便宜有口碑
this.treeList.ParentFieldName = "Father_City_Id";
this.treeList.KeyFieldName = "CityId";
差不多就是这样
另外,团IDC网上有许多产品团购,便宜有口碑
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询