精易论坛

标题: 动态插入N项数组到框框 [打印本页]

作者: stillness    时间: 2012-11-30 19:22
标题: 动态插入N项数组到框框


  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. //私の艹 #define Rnd 888; 定不了?
  10. //#define new Rad 888
  11. /* [*] */
  12. namespace 插入N个项目到框框
  13. {
  14.     public partial class _Main : Form
  15.     {
  16.         public _Main()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         public static int define_随机数 = 8888;   
  21.         private void button1_Click(object sender, EventArgs e)
  22.         {
  23.             string[] Temp_Hwnd = new string[2];
  24.             Temp_Hwnd[1] = this.Text;
  25.             if (listBox1.Items.Count < 1)
  26.             {
  27.                 Random Rnd = new Random();
  28.                 int[] A = new int[2];
  29.                 A[0] = Rnd.Next(1, define_随机数);
  30.                 for (A[2 - 1] = 1; A[2 - 1] <= A[1-1]; A[2-1]++)
  31.                 {
  32.                     listBox1.Items.Add(A[2 - 1].ToString());
  33.                 }
  34.                 System.Console.WriteLine(listBox1.Items.Count.ToString());
  35.                 // 标准输出流
  36.                 // Win32,64下不做任何作用
  37.                 MessgeBoxA(FindWindow(Temp_Hwnd [0],Temp_Hwnd[1]), listBox1.Items.Count.ToString()+"项", "信息:", 64 + 0);
  38.                 // MessageBox.Show(Convert.ToInt32(_Main.ActiveForm.ToString()), listBox1.Items.Count.ToString(), "信息:", 64 + 0);   
  39.             }
  40.             else
  41.             {
  42.                 listBox1.Items.Clear();
  43.                 MessgeBoxA(FindWindow(Temp_Hwnd[0], Temp_Hwnd[1]), "删除完毕", "信息:", 64 + 0);
  44.             }
  45.             object ojb = new object() ;
  46.             EventArgs R = new EventArgs();
  47.             Form1_Load(ojb,R);
  48.         }
  49.         [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FindWindow")]
  50.         private static extern int FindWindow(string ClassName, string IpName);
  51.         [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "MessageBoxA")]
  52.         private static extern int MessgeBoxA(int Hwnd,string Tip,string Text,int val);
  53.         private void Form1_Load(object sender, EventArgs e)
  54.         {
  55.             label1.Text = "";
  56.             this.Text = "动态加入N项到框框";
  57.             if ((this.timer1.Enabled == true) == false)
  58.             {
  59.                 timer1.Enabled = true;
  60.             }
  61.             if (listBox1.Items.Count > 0)
  62.             {
  63.                 this.button1.Text = "删除" + 指针递加符("R",true); // 递加符可为D异可为R
  64.             }
  65.             else
  66.             {
  67.                 this.button1.Text = "添加"+指针递加符("A",Not(false));// 递加符可为A亦可为其他
  68.             }
  69.             // 采集递加﹣异或为英文字符
  70.         }
  71.         bool Not(bool 欲反转逻辑值)
  72.         {
  73.             return !(欲反转逻辑值);
  74.         }
  75.         private void timer1_Tick(object sender, EventArgs e)
  76.         {
  77.             DateTime Time = new DateTime();
  78.             this.label1.Text = Time.TimeOfDay.ToString();
  79.             this.label1.Update();
  80.         }
  81.         string 指针递加符(string Fue,bool val)
  82.         {
  83.             string Ret;
  84.             if (val == true)
  85.             {
  86.                 Ret = ("(&".ToString()) + ((string)Fue) + ")".ToString();
  87.             }
  88.             else
  89.             {
  90.                 Ret = "&" + Fue;
  91.             }
  92.             return Ret;
  93.         }
  94.     }
  95. }

复制代码
插入N个项目到框框.rar (46.84 KB, 下载次数: 3)


作者: 猫星人    时间: 2013-3-17 13:13
用了一下,感觉不错,学习了。。




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4