请问如何在程序中动态地添加ComboBox的items?

fanself 2001-07-21 04:12:57
...全文
233 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
victorchen_2000 2001-07-24
  • 打赏
  • 举报
回复
你想问就问啊,不可能你问了我不回答你的,也不可能你不问我要回答你的,
Sephil 2001-07-24
  • 打赏
  • 举报
回复
怎么吵起来了
fanself 2001-07-24
  • 打赏
  • 举报
回复
如果我烦着你了,你可不看我的贴子
fanself 2001-07-24
  • 打赏
  • 举报
回复
!(!(大大有助于提升 CSDN 的问题平均水平))
你解决了问题没有,没有,就没发言权。
我看书,我试,没出来,当然就问你罗。要不,我改行不作BCB,
我不如你才问你啊。
fanself 2001-07-24
  • 打赏
  • 举报
回复
我不可能在这里提问,指着谁来回答的。
以后还是换地方吧,此地不宜久留。
我的问题都不受欢迎,88罗。
Greenleaf 2001-07-24
  • 打赏
  • 举报
回复
楼上的兄弟说得好
fanself 2001-07-22
  • 打赏
  • 举报
回复
好的,不过这方法好像。。。。。。算了,给你吧。。。
whitelion 2001-07-22
  • 打赏
  • 举报
回复
怎么连我都不如
whitelion 2001-07-22
  • 打赏
  • 举报
回复
看看书
多试试
SCUM 2001-07-22
  • 打赏
  • 举报
回复


此问题问得好

大大有助于提升 CSDN 的问题平均水平

对不起,忘了加 “!” 号

应改为

!(大大有助于提升 CSDN 的问题平均水平)






Chxis 2001-07-22
  • 打赏
  • 举报
回复
哈~~
Wingsun 2001-07-22
  • 打赏
  • 举报
回复
给分啦!
xycleo 2001-07-22
  • 打赏
  • 举报
回复
对阿!!怎么还不给???难道................??
halfdream 2001-07-22
  • 打赏
  • 举报
回复
fanself(雨轩客)  到底想要什么呢?想要就说嘛。。。
rh 2001-07-22
  • 打赏
  • 举报
回复
给啊?
lovebcb 2001-07-21
  • 打赏
  • 举报
回复
xzgyb() HorkyTao(流浪者) 
说的对
xzgyb 2001-07-21
  • 打赏
  • 举报
回复
那就存文件里,ComboBox->Items->SaveToFile("a.dat");
下一次在ComboBox->Items->LoadFromFile("a.dat");
fanself 2001-07-21
  • 打赏
  • 举报
回复
你的方法是不行的,那样怎么能保证第二次,你所加的东西还在呢?
不给分。
我不懂电脑 2001-07-21
  • 打赏
  • 举报
回复
慢了
火鸟33 2001-07-21
  • 打赏
  • 举报
回复
我的网络好慢
加载更多回复(2)
WPF 秒表 计时器 定时关机 到计时关机 public const uint WM_SYSCOMMAND = 0x0112; public const uint SC_MONITORPOWER = 0xF170; [DllImport("user32")] public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam); /// /// 关闭显示器 /// public void CloseScreen() { IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle; SendMessage(windowHandle, WM_SYSCOMMAND, SC_MONITORPOWER, 2); // 2 为关闭显示器, -1则打开显示器 } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; using IniFiles; namespace StopWatch { /// /// shutdonwCtrl.xaml 的交互逻辑 /// public partial class shutdonwCtrl : UserControl { DispatcherTimer timer1; DispatcherTimer timer2; public shutdonwCtrl() { InitializeComponent(); timer1 = new DispatcherTimer(); timer1.Tick += new EventHandler(OnTimer1); timer1.Interval = new TimeSpan(0, 0, 1); timer2 = new DispatcherTimer(); timer2.Tick += new EventHandler(OnTimer2); timer2.Interval = new TimeSpan(0, 0, 1); btn_cancel.IsEnabled = false; cancel1.IsEnabled = false; } IniFile INI = new IniFile(IniFile.AppIniName); public void LoadIni() { cbo_hour.Text = INI.ReadString("定时关机", "时", "0"); cbo_Minute.Text = INI.ReadString("定时关机", "分", "0"); cbo_Second.Text = INI.ReadString("定时关机", "秒", "0"); cbo1.Text = INI.ReadString("到计时关机", "分", "0"); //combobox1.Text = INI.ReadString("到计时", "时", "0"); //combobox2.Text = INI.ReadString("到计时", "分", "0"); //combobox3.Text = INI.ReadString("到计时", "秒", "0"); } public void SaveIni() { INI.WriteString("定时关机", "时", cbo_hour.Text); INI.WriteString("定时关机", "分", cbo_Minute.Text); INI.WriteString("定时关机", "秒", cbo_Second.Text); INI.WriteString("到计时关机", "分", cbo1.Text); } private void ShutDown() { System.Diagnostics.Process.Start("shutdown.exe", "-s -t 1"); } private void OnTimer1(object sender,EventArgs e) { if (second > 0) second--; label1.Content = string.Format("Windows将在 {0} 关机", TimerClass.GetTimeString1(second)); if (second <= 0 && !cbo1.IsEnabled) { ShutDown(); } } int second = 0; private void Button_Click(object sender, RoutedEventArgs e) { second = Convert.ToInt32(cbo1.Text) * 60; if (second <= 0) { MessageBox.Show("数值必须大于0!"); return; } timer1.Start(); cbo1.IsEnabled = false; cancel1.IsEnabled = true; start1.IsEnabled = false; } private void Button_Click_1(object sender, RoutedEventArgs e) { label1.Content = " "; timer1.Stop(); second = 0; cbo1.IsEnabled = true; cancel1.IsEnabled = false; start1.IsEnabled = true; } private void OnTimer2(object sender, EventArgs e) { if ( DateTime.Now.Hour == Convert.ToInt32(cbo_hour.Text) && DateTime.Now.Minute == Convert.ToInt32(cbo_Minute.Text) && DateTime.Now.Second == Convert.ToInt32(cbo_Second.Text) ) { ShutDown(); } } private void Button_Click_2(object sender, RoutedEventArgs e) { int s = Convert.ToInt32(cbo_hour.Text) * 3600 + Convert.ToInt32(cbo_Minute.Text) * 60 + Convert.ToInt32(cbo_Second.Text); timer2.Start(); label2.Content = string.Format("Windows将在 {0} 关机", TimerClass.GetTimeString1(s)); btn_start.IsEnabled = false; btn_cancel.IsEnabled = true; cbo_hour.IsEnabled = false; cbo_Minute.IsEnabled = false; cbo_Second.IsEnabled = false; } private void btn_cancel_Click(object sender, RoutedEventArgs e) { label2.Content = ""; timer2.Stop(); btn_start.IsEnabled = true; btn_cancel.IsEnabled = false; cbo_hour.IsEnabled = true; cbo_Minute.IsEnabled = true; cbo_Second.IsEnabled = true; } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Threading.Tasks; using System.Runtime.InteropServices; using System.Windows.Threading; using IniFiles; namespace StopWatch { /// /// TimerCtrl.xaml 的交互逻辑 /// public partial class TimerCtrl : UserControl { private DispatcherTimer timer1 = null; private DispatcherTimer timer2 = null; int SND_SYNC = 0x0000; /* play asynchronously */ //异步 int SND_ASYNC = 0x0001; int SND_LOOP = 8; [DllImport("winmm")] public static extern bool PlaySound(string szSound, IntPtr hMod, int flags); private void playSound3() { Task tsk = new Task(new Action(proc)); tsk.Start(); } private void proc() { PlaySound(@"Sound\2.wav", IntPtr.Zero, SND_SYNC); PlaySound(@"Sound\2.wav", IntPtr.Zero, SND_SYNC); PlaySound(@"Sound\2.wav", IntPtr.Zero, SND_SYNC); } public TimerCtrl() { InitializeComponent(); timer1 = new DispatcherTimer(); timer1.Tick += new EventHandler(OnTimer1); timer1.Interval = new TimeSpan(0, 0, 1); timer2 = new DispatcherTimer(); timer2.Tick += new EventHandler(OnTimer2); timer2.Interval = new TimeSpan(0, 0, 1); btn_reset1.IsEnabled = false; btn_pause1.IsEnabled = false; } int h = 0; int m = 0; int s = 0; int seconds = 0; private void OnTimer1(object sender, EventArgs e) { if (seconds < 1) { PlaySound(@"Sound\2.wav", IntPtr.Zero, SND_ASYNC); btn_start.IsEnabled = false; btn_reset1.IsEnabled = true; btn_pause1.IsEnabled = false; combobox1.IsEnabled = true; combobox2.IsEnabled = true; combobox3.IsEnabled = true; return; } seconds--; label1.Content = TimerClass.GetTimeString1(seconds); } private void btn_start_Click(object sender, RoutedEventArgs e) { h = Convert.ToInt32(combobox1.Text); m = Convert.ToInt32(combobox2.Text); s = Convert.ToInt32(combobox3.Text); seconds = h * 3600 + m * 60 + s; label1.Content = TimerClass.GetTimeString1(seconds); timer1.Start(); btn_start.IsEnabled = false; btn_reset1.IsEnabled = true; btn_pause1.IsEnabled = true; combobox1.IsEnabled = false; combobox2.IsEnabled = false; combobox3.IsEnabled = false; } private void btn_reset_Click(object sender, RoutedEventArgs e) { seconds = 0; label1.Content = TimerClass.GetTimeString1(seconds); timer1.Stop(); btn_start.IsEnabled = true; btn_reset1.IsEnabled = false; btn_pause1.IsEnabled = false; combobox1.IsEnabled = true; combobox2.IsEnabled = true; combobox3.IsEnabled = true; } private void pause1_Click(object sender, RoutedEventArgs e) { if (btn_pause1.Content.ToString() == "暂停") { timer1.Stop(); btn_pause1.Content = "继续"; } else { timer1.Start(); btn_pause1.Content = "暂停"; } } int SEC = 0; private void OnTimer2(object sender, EventArgs e) { if (SEC < 1) { timer2.Stop(); playSound3(); btn_quick.IsEnabled = true; btn_cancel2.IsEnabled = false; combobox4.IsEnabled = true; return; } SEC--; label4.Content = TimerClass.GetTimeString1(SEC); } private void Button_Click(object sender, RoutedEventArgs e) { SEC = Convert.ToInt32(combobox4.Text) * 60; timer2.Start(); combobox4.IsEnabled = false; btn_quick.IsEnabled = false; btn_cancel2.IsEnabled = true; } private void Button_Click_1(object sender, RoutedEventArgs e) { SEC = 2; label4.Content = "00:00:00"; timer2.Stop(); combobox4.IsEnabled = true; btn_quick.IsEnabled = true; } IniFile INI = new IniFile(IniFile.AppIniName); public void LoadIni() { combobox1.Text = INI.ReadString("到计时", "时", "0"); combobox2.Text = INI.ReadString("到计时", "分", "0"); combobox4.Text = INI.ReadString("快速计时", "分", "0"); } public void SaveIni() { INI.WriteString("到计时", "时", combobox1.Text); INI.WriteString("到计时", "分", combobox2.Text); INI.WriteString("到计时", "秒", combobox3.Text); INI.WriteString("快速计时", "分", combobox4.Text); } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Threading; using System.Windows.Threading; namespace StopWatch { /// /// WatchCtrl.xaml 的交互逻辑 /// public partial class WatchCtrl : UserControl { public WatchCtrl() { InitializeComponent(); timer1 = new DispatcherTimer(); timer1.Tick += new EventHandler(OnTimer1); timer1.Interval = new TimeSpan(0, 0, 1); timer1_1 = new DispatcherTimer(); timer1_1.Tick += new EventHandler(OnTimer1_1); timer1_1.Interval = new TimeSpan(0, 0, 0, 100); timer2 = new DispatcherTimer(); timer2.Tick += new EventHandler(OnTimer2); timer2.Interval = new TimeSpan(0, 0, 1); } private DispatcherTimer timer1 = null; private DispatcherTimer timer1_1 = null; private DispatcherTimer timer2 = null; private void OnTimer1(object sender, EventArgs e) { second++; label1.Content = TimerClass.GetTimeString1(second) ;//DateTime.Now.ToString("h:mm:ss"); } public int second = 0; private int second1 = 0; public int count = 0; private void OnTimer1_1(object sender, EventArgs e) { //label1.Content = TimerClass.GetTimeString1(second) + "." + count.ToString();//DateTime.Now.ToString("h:mm:ss"); //count++; //if (count > 9) // count = 0; } private void OnTimer2(object sender, EventArgs e) { second1++; label2.Content = TimerClass.GetTimeString1(second1) ;//.ToString("h:mm:ss"); } private void btn_start_Click(object sender, RoutedEventArgs e) { timer1.Start(); timer2.Start(); if (btn_start.Content.ToString() == "停止") { btn_start.Content = "开始"; btn_reset.Content = "复位"; timer1.Stop(); timer2.Stop(); } else { btn_start.Content = "停止"; btn_reset.Content = "计次"; } } private int counter = 0; private void btn_reset_Click(object sender, RoutedEventArgs e) { if (btn_reset.Content.ToString() == "复位") { second = 0; second1 = 0; label1.Content = "00:00:00"; label2.Content = "00:00:00"; timer1.Stop(); timer2.Stop(); } else { if (second1 > 0) { counter++; listbox1.Items.Add(string.Format(" {0}\t{1}", counter, label2.Content)); } second1 = 0; label2.Content = "00:00:00"; } if (btn_reset.Content.ToString() == "复位" && btn_start.Content.ToString()=="开始") { listbox1.Items.Clear(); } } } }
vs2015+数据库,需要建的数据表如下: 1. “考试成绩管理系统用户登录”功能 具体要求: (1) 按照图示排列相应的控件,控件名称自定义,其,界面的图片可以不加; (2) 当输入正确的用户名和密码时,登录到主系统,如图所示,并且用户名或密码输入不正确时系统有所提示;当单击【取消】按钮时,用户名和密码被清空; (3) 程序用到的数据库名为SCOREINFO,数据表名为userinfo,数据表结构如下图所示: (4) 数据表的用户名和密码如下图。 2. 点击主窗体的“密码修改”菜单,完成“密码修改”功能,程序运行如下图所示: 具体要求: (1)此题必须使用数据库连接完成,原始密码必须为数据表里原有的数据,不使用数据库完成的为0分。 (2)需要建立数据库SCOREINFO及数据表userinfo,表的结构及数据第一部分的内容: (3)要有“原始密码输入错误”、“原始密码不能为空”及“两次输入密码不一致”的错误提示; (4)当单击【保存】按钮,新密码被更新到数据表,不能更新的为0分; (5)单击【关闭】按钮,窗口关闭。 (6)3个Label;3个TextBox;2个Button 3. 完成“成绩查询”功能,程序运行如下图所示: 具体要求: (1) 按照图示排列相应的控件,界面下方是DataGridView控件; (2)程序用到的数据库名为SCOREINFO,数据表名为score,表结构如下: (3)完成的MainForm_Load事件处理程序:当加载窗体时,直接在窗体的dataGridView1控件显示数据表的所有记录; (4)可以设查询条件:首先在组合框comboBox1选择查询条件,并在textBox1输入条件值(可以模糊查询,如按照姓名查询时,输入“王”,可以查所有姓王的同学的成绩),单击查询将结果显示在dataGridView1控件。 (5)所需控件及属性:1个GroupBox,1个Label,Text为选择查询条件;1个ComboBoxItems:学号、姓名);1个TextBox;1个Button,Text为查询;1个DataGridView 4. 完成“课程信息修改”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义,其程序刚开始运行时,“学分”和“课程编码”的文本框是只读的; (2)在数据库名为SCOREINFO,创建数据表名为course,表结构如下: (3)当单击【查询】时,直接在窗体的dataGridView2控件显示数据表的所有记录; (4)当选DataGridView控件的某一行记录时(DataGridView控件的Mouse_Click事件),“课程名字”、“学分”、“课程代码”文本框分别显示该项对应的课程信息; (5)当选某一行记录并单击【编辑】按钮时,【编辑】按钮变为【保存修改】,同时“学分”和“课程编码”的文本框恢复正常(ReadOnly属性为false);在文本框修改相应的信息后单击【保存修改】,将修改后的数据更新到数据表。 (6)所需控件及属性:1个GroupBox,3个Label;3个TextBox(textBox2属性ReadOnly为True,textBox3属性ReadOnly为True);2个Button;1个DataGridView 5. 完成“课程信息删除”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义,其程序刚开始运行时,“学分”和“课程编码”的文本框是只读的; (2)数据表名为course,表结构同第4部分: (3)当单击【查询】时,直接在窗体的dataGridView控件显示数据表的所有记录; (4)当选DataGridView控件的某一行记录时,“课程名字”、“学分”、“课程代码”文本框分别显示该项对应的课程信息; (5)当选某一行记录并单击【删除】按钮时,则该行从数据表删除。 (6)所需控件:3个Label;3个TextBox(textBox2属性ReadOnly为True,textBox3属性ReadOnly为True);2个Button;1个DataGridView 6. 完成“课程信息添加”功能,程序运行如下图所示: 具体要求: (1)按照图示排列相应的控件,控件名称自定义; (2)程序用到的数据库和数据表名为course,表结构如下同第四部分: (3)当单击【查询】时,直接在窗体的dataGridView1控件显示数据表的所有记 (4)当选DataGridView控件的某一行记录时,“课程名字”、“学分”、“课程代码”文本框分别显示该项对应的课程信息; (5)当单击【添加】按钮时,在文本框添加新的内容并将新内容添加到数据表,并且在DataGridView控件显示出新的课程信息 (6)所需控件:3个Label;3个TextBox;2个Button;1个DataGridView

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧