在单击添加按钮时,我希望文本框应显示???????? [英] On the click of the add button i want the textbox should display????????

查看:62
本文介绍了在单击添加按钮时,我希望文本框应显示????????的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体上有4个值的Apple,Oranges,Kiwi和Bread combox.我想基于组合框中选择的值以相同的形式更新文本框中的代码.因此,如果Apple在组合框中被选中,则代码应用程序应显示组合框中的奇异果是否比文本框中的值是奇异,依此类推.

我已将所有数据保留在组合框中,但尚未为此创建任何数据.

1.是否必须为此创建Sql Data,然后必须进行连接?

请朋友,我没有4个项目,我还有30个数据,所以请让我知道我如何在组合框中管理此数据


================================================== ================

在单击添加按钮时,文本框应显示我编写的代码,该代码给我错误

I have combox with 4 values Apple,Oranges,Kiwi and Bread on windows form. I want to update a code in textbox on same form based on value selected in combobox. so if Apple got selected in combobox, code app should show if kiwi in combobox than value in text box is kiw and so on.

I have kept all data in combo box i have not create any data for this.

1. Do i have to create Sql Data for this and then i have to do the connection?

please friends i don''t have only 4 item i have data more the 30 so please let me know how i manage this data in combo box


==================================================================

On the click to the add button the text box should display the code which i have written it gives me error

private void button2_Click(object sender, EventArgs e)
       {
           frmsalesorderbooking f2 = new frmsalesorderbooking();
           groupBox1 gb = new GroupBox1();
           int topPosition = 5;
           for (int j = 0; j < Convert.ToInt32(textBox6.Text.ToString()); j++)
           {
               comboBox2 cb = new ComboBox1();
               cb.left = 5;
               cb.top = topPosition;
               topPosition += 30;
               gb.controls.Add(cb);
           }
           frmsalesorderbooking.Control.Add(gb);
           frmsalesorderbooking.show();
       }






在此先感谢:rose :: rose:






Thanks in Advance :rose::rose:

推荐答案

此查询不需要SQL数据和SQL连接,您可以通过这种方式非常轻松地解决问题

将数据Apple,Oranges,Kiwi和Bread添加到您的组合框,然后编写
给定组合框的SelectedIndexChanged事件中的代码.

There is no Need for SQL Data and SQL Connection for this Query you can solve your problem very easly by this way

Add Data Apple,Oranges,Kiwi and Bread your Combobox and then write the
given code in SelectedIndexChanged Event of Combobox.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
     {
         textBox1.Text = comboBox1.Text;
     }


尝试此代码非常简单.

还是您想要其他东西?

Try this code It''s Quite EASY.

Or you want something else??

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text = "RED" Then
            TextBox1.Text = "RED SELECTED"
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Add("RED")
    End Sub



:cool :: cool :: cool :: cool :: cool :: cool:



:cool::cool::cool::cool::cool::cool:


希望这就是您想要的!

在母版页窗口中加载子:

私人子Window1_loaded(..........)
combobox1.items.add("Apple")
combobox1.items.add("Kiwi")
.
.
结束子

然后创建另一个函数来加载这些项目..我将在此处使用列表,因为您可能拥有30多个项目..

公共函数AddInList()作为List(of String)

昏暗的lst作为列表(字符串)

对于i = 0到combobox1.items.count
lst.add(combobox1.items(i))
下一个我

返回lst

最终功能

现在在您的子产品页面中:

在该子产品的已加载子代码中执行此操作:

将w变暗为window1
将myList变暗为List(of string)= w.AddInList()

然后

对于我作为整数= 0到myList.count
combobox2.items.add(myList(i).toString())
下一个我

textbox2.text = combobox2.selectedItem()


希望这可以帮助!! :)
hope this is what u want!

in master page''s window loaded sub:

private sub Window1_loaded(..........)
combobox1.items.add("Apple")
combobox1.items.add("Kiwi")
.
.
end sub

then create another function to load these items.. i will use a list here coz u may hav more than 30 items..

public function AddInList() as List(of String)

dim lst as list(of string)

for i=0 to combobox1.items.count
lst.add(combobox1.items(i))
next i

return lst

end function

Now in your sub-product page:

do this in that sub-product''s loaded sub:

dim w as window1
dim myList as List(of string)=w.AddInList()

and then

for i as integer=0 to myList.count
combobox2.items.add(myList(i).toString())
next i

textbox2.text=combobox2.selectedItem()


Hope this helps!! :)


这篇关于在单击添加按钮时,我希望文本框应显示????????的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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