private void Form2_Load(object sender, EventArgs e) { dataGridView1.AllowUserToAddRows = true; //如果选中DATAGRIDVIEW某行其中某个单元格(列)是空值,进行相应的特殊处理 //data source,user id,password不区分大小写 OracleConnection con = new OracleConnection("data Source=orcl;user id=scott;password=system"); OracleCommand comm = new OracleCommand(); comm.Connection = con; comm.CommandText = "select deptno,dname,loc from dept"; comm.CommandType = CommandType.Text; da= new OracleDataAdapter(comm); ds1 = new DataSet(); oda.Fill(ds1); dataGridView1.DataSource = ds1.Tables[0]; //学习显示图像控件的相关用法 //要显示的图像资源 // 因为在C# \是特殊字符,为了显示它,用转义字符\\表示\ //Bitmap image1 = (Bitmap)Image.FromFile(@"image1.bmp", true); //要显示的图像资源,fromfile表示自什么地方创建图像资源,true表示使用图像文件的颜色管理方案 Image image1 = Image.FromFile(@"f:\image1.bmp",true); //Image im = Image.FromFile(@"f:\image.bmp",true); //imagelist是个装载多个图像image的控件,显示图像控件是picturebox,它显示的图像源于imagelist中某个image imageList1.Images.Add(image1); //imagelist.imagesize为图像集中每个图像的大小 imageList1.ImageSize = new Size(250,250); pictureBox1.Image = imageList1.Images[0]; } 示例代码运行结果: |
image1.JPG
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-717325/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-717325/