社区
C#
帖子详情
急!!我是新手,望各位大哥回答!
lovepei99
2004-12-21 07:21:52
在一个WINDOWS应用程序中
放置 一个COMBOBOX控件,和一个DATAGRID
希望在FORM_LOAD事件中先绑定COMBOBOX,
然后在COMBOBOX中有一个SelectedIndexChanged 事件
希望在COMBOBOX里选择一个直之后能在DATAGRID中显示出符合所选值的几列数据
哪位大哥告诉我啊~~~~~不胜感激!!
...全文
105
7
打赏
收藏
急!!我是新手,望各位大哥回答!
在一个WINDOWS应用程序中 放置 一个COMBOBOX控件,和一个DATAGRID 希望在FORM_LOAD事件中先绑定COMBOBOX, 然后在COMBOBOX中有一个SelectedIndexChanged 事件 希望在COMBOBOX里选择一个直之后能在DATAGRID中显示出符合所选值的几列数据 哪位大哥告诉我啊~~~~~不胜感激!!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
lovepei99
2004-12-21
打赏
举报
回复
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private string ConString="Data Source=oradb1;User Id=htl_manager;Password=111;";
private DataSet ruzhuDs;
private OracleConnection ruzhuConn ;
private OracleDataAdapter ruzhuDa;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(144, 248);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(392, 80);
this.dataGrid1.TabIndex = 0;
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(144, 80);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 1;
this.comboBox1.Text = "comboBox1";
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(144, 128);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(112, 21);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(384, 144);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 3;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(144, 192);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 4;
this.textBox3.Text = "textBox3";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(408, 176);
this.textBox4.Name = "textBox4";
this.textBox4.TabIndex = 5;
this.textBox4.Text = "textBox4";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(616, 445);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//BindCombobox();
ruzhuConn= new OracleConnection(ConString);
string strSql="select * from room_lev_table ";
ruzhuDs= new DataSet("room_lev_table");
//DataSet ds=new DataSet("room_table");
//OracleDataAdapter da=new OracleDataAdapter(strSql,cn);
ruzhuDa = new OracleDataAdapter(strSql,ruzhuConn);
ruzhuDa.Fill(ruzhuDs,"room_lev_table");
comboBox1.DataSource=ruzhuDs.Tables["room_lev_table"];
comboBox1.DisplayMember = ruzhuDs.Tables ["room_lev_table"].Columns[1].ColumnName;
comboBox1.ValueMember = ruzhuDs.Tables["room_lev_table"].Columns[0].ColumnName;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
ruzhuConn= new OracleConnection(ConString);
string strSql="select * from room_table where room_num='"+comboBox1.SelectedValue+"'";
ruzhuDs=new DataSet("room_table");
ruzhuDa=new OracleDataAdapter(strSql,ruzhuConn);
ruzhuDa.Fill(ruzhuDs);
dataGrid1.DataSource = ruzhuDs;
dataGrid1.DataMember ="room_table";
}
各位大哥帮忙看看啊!
Alden
2004-12-21
打赏
举报
回复
应该很简单的,你好好检查检查代码,或者把代码贴出来。
hanyaocsdn
2004-12-21
打赏
举报
回复
up
Ivony
2004-12-21
打赏
举报
回复
据你所说,最有可能就是你的cs文件里面的控件的名字(如DataGrid)与你的aspx文件里面的标签(如<asp:DataGrid.....>)的ID属性不匹配。
lovepei99
2004-12-21
打赏
举报
回复
我每次运行都会出现 “未将对象引用设置到对象的实例”?
这是什么意思啊
怎么解决~
急!
lovepei99
2004-12-21
打赏
举报
回复
InterMa(因特马) 大哥 ,帮帮忙啊 !
InterMa
2004-12-21
打赏
举报
回复
这个。。。。。。。。
你都说的相当明白了,没什么难点阿,怎么不会编呢?
被问“为什么你们项目不用 JPA 用 MyBatis?”我这样
回答
拿下了 offer!
别慌,以下是我常总结的几个“面试高频坑”:1.返回值是 List,resultType 写错成对象类型正确写法:resultType="com.xxx.User" 用在返回单个对象上;返回列表时,要么配好 resultMap,要么用 resultType="User" 并...
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using passwor:yes) MyQL8.0
跟这位
大哥
的操作,可惜我出来的是这样。(@acoolgiser) 我觉得应该授权的问题,于是我往这方面找。 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用...
面试总结,坚定自己的想法
今天想跟大家谈谈心,最近面试了一家公司,其中面试官问了我几个问题,我觉得这些问题是每一个跳槽的人都会被问道的,下面我结合我的
回答
来说说! 任何一次的跳槽都是跟 “薪资” 和 “个人职业发展” 这两方面...
如果我是面试官
本来想写一个系列的,一半是抨击现在面试之水,要人之奸,用
大哥
的话说,要走
新手
是做螺丝钉和抹布用的。另一半是对出出学校的或者是自废武功转3d的朋友们提供一个比较有价值的参考。不过我时间实在仓促。没有保证,...
股票群的骗术 ,几乎99%的QQ群
诈骗手法如下:9点30前推荐3支在竞价时间已经大涨或者突然拉升3%左右的股票来诈骗
新手
,
新手
一看,是9点30前推荐的,从而上当受骗,开盘后,3支股票,有涨有跌,如果涨了QQ群群主就大势宣传.不涨就说已经提前布局,...
C#
111,098
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章