在comboBox选择值后,textBox自动显示与comboBox相连接的值!
发布网友
发布时间:2022-04-30 05:29
我来回答
共2个回答
热心网友
时间:2023-10-17 03:48
获取combobox的change事件,事件类型是IndexChangeEvent,然后再事件方法中根据combobox选择的条目信息判断label的文本变化就可以了,这个问题查flex api是可以解决的
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=""
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
public var cards:ArrayCollection = new ArrayCollection(
[ ,
]);
protected function combobox2_changeHandler(event:IndexChangeEvent):void
{
//中文
if(cb.selectedItem.data == 1)
{
ac.text = "中文";
}
//English
else
{
ac.text = "English";
}
}
]]>
</fx:Script>
<s:VGroup>
<s:ComboBox id="cb" change="combobox2_changeHandler(event)" dataProvider=""/>
<s:Label width="100" text="TEXT。。。" id="ac"/>
</s:VGroup>
</s:Application>
热心网友
时间:2023-10-17 03:48
你可以把绑定写到外面:
public void ComBind()
{String MySQLConnectionString = global::WindowsFormsApplication1.Properties.Settings.Default.testConnectionString;
string MySQL = "SELECT DISTINCT a3 FROM test1 WHERE (a2 ='" + this.comboBox1.Text + "')";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
System.Data.DataTable MyTable = new System.Data.DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyTable);
this.comboBox1.DataSource = MyTable;
this.comboBox1.DisplayMember = "a2";
this.comboBox1.ValueMember = "a3";
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
ptotect void com_select(object sender,eventargs e)
{
textbob.text=combox.comboBox1.SelectedValue.ToString();
ComBind();
}
理论上你的那种做法是没有错误的。
如果不行,你换这个试试~!
热心网友
时间:2023-10-17 03:48
获取combobox的change事件,事件类型是IndexChangeEvent,然后再事件方法中根据combobox选择的条目信息判断label的文本变化就可以了,这个问题查flex api是可以解决的
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx=""
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
public var cards:ArrayCollection = new ArrayCollection(
[ ,
]);
protected function combobox2_changeHandler(event:IndexChangeEvent):void
{
//中文
if(cb.selectedItem.data == 1)
{
ac.text = "中文";
}
//English
else
{
ac.text = "English";
}
}
]]>
</fx:Script>
<s:VGroup>
<s:ComboBox id="cb" change="combobox2_changeHandler(event)" dataProvider=""/>
<s:Label width="100" text="TEXT。。。" id="ac"/>
</s:VGroup>
</s:Application>
热心网友
时间:2023-10-17 03:48
你可以把绑定写到外面:
public void ComBind()
{String MySQLConnectionString = global::WindowsFormsApplication1.Properties.Settings.Default.testConnectionString;
string MySQL = "SELECT DISTINCT a3 FROM test1 WHERE (a2 ='" + this.comboBox1.Text + "')";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
System.Data.DataTable MyTable = new System.Data.DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyTable);
this.comboBox1.DataSource = MyTable;
this.comboBox1.DisplayMember = "a2";
this.comboBox1.ValueMember = "a3";
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
ptotect void com_select(object sender,eventargs e)
{
textbob.text=combox.comboBox1.SelectedValue.ToString();
ComBind();
}
理论上你的那种做法是没有错误的。
如果不行,你换这个试试~!