C#.net中的动态属性-帮帮我 [英] Dynamic Properties in C#.net -- Help me

查看:56
本文介绍了C#.net中的动态属性-帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,
我在C#.net中创建了一个动态组合框.如果我想要3组合框.我会在Loop语句中给出这样的内容...

Hi friends,
I created a dynamic Combobox in C#.net.If i want 3 Combobox. I will give in Loop statement.like this...

 public static System.Windows.Forms.GroupBox gb;
       public static System.Windows.Forms.TextBox txt;
       public static System.Windows.Forms.Button  test;
       public static System.Windows.Forms.RadioButton  chk;
       public static System.Windows.Forms.ComboBox cmb;
gb = new GroupBox();
           gb.Name = "GroupName" ;
           gb.Text = "Virtual COM Port";
           gb.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
           gb.Width = 750;
           gb.Height = 250;
           gb.Left = 10;
           gb.Top = 20 ;
           this.Controls.Add(gb);
           int i;
           for (i = 0; i < 3; i++)
           {


               cmb = new ComboBox();
               cmb.Name = "combobox" + i.ToString();
               cmb.Text ="Combo"+i.ToString();
               cmb.Width = 100;
               cmb.Height = 20;

               cmb.Left = 15;
               cmb.Top = 20 + (cmb.Height * i) + (10 * i); //initial + height + padding
               cmb.DropDownStyle = ComboBoxStyle.DropDownList;
               cmb.Items.Add("COM5");
               cmb.Items.Add("COM6");


               txt = new TextBox();
               txt.Name = "Textbox" + i.ToString();
               txt.Text = "Testtext" + i.ToString();
               txt.Width = 150;
               txt.Height = 20;
               txt.Left = 150;
               txt.Top = 20 + (txt.Height * i) + (10 * i);

               chk = new RadioButton();
               chk.Name = "RB" + i.ToString();
               chk.Text = "Enabled";
               chk.Width = 100;
               chk.Height = 20;
               chk.Left = 320;
               chk.Top = 20 + (chk.Height * i) + (10* i); //initial + height + padding

               gb.Controls.Add(cmb);
               gb.Controls.Add(txt);
               gb.Controls.Add(chk);
          }
       }


所以我得到了3个Combobox,Textbox,Radiobutton和One Groupbox.现在,我将之前的记录与当前的记录进行比较.例如:
我选择一个Combobox1 ="COM5"
Combobox2 ="COM5"
Combobox3 ="COM6"
这里Combobox1和Combobox2的值是相同的.所以我想同时显示错误消息框,我将检查文本框值.请帮助我.
问候,
Lakshmi Narayanan.S


So i got a 3 Combobox,Textbox,Radiobutton and One Groupbox.Now i compare to previous records with current record. For example:
I select a Combobox1 ="COM5"
Combobox2 ="COM5"
Combobox3 ="COM6"
Here Combobox1 and Combobox2 values are same . SO i want Error message box at the same time i will check the textbox value .Please help me.
Regards,
Lakshmi Narayanan.S

推荐答案

您要做的就是比较两个组合的文本.

但是,另一种选择是从其余的组合中删除重复的选项.
All you have to do is compare the text of both combo''s.

But, another option would be to just remove the duplicate option from the remaining combos.


这篇关于C#.net中的动态属性-帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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