Пример #1
0
 private void PicItem_Click(object sender, EventArgs e)
 {
     // 피쳐박스 크기 최대화 및 이전 사이즈로
     if (this.PicItem.Dock == System.Windows.Forms.DockStyle.Fill)
     {   //이미지가 가득 채워져있으면 원상태로 바꾸어라.
         this.PicItem.Dock = System.Windows.Forms.DockStyle.None;
     }
     else
     {
         PicItem.Dock = System.Windows.Forms.DockStyle.Fill;
         PicItem.BringToFront();
         // 이미지가 가득 채워져 있지 않으면 가득 채워라.
         //이미지를 가장 앞으로 가지고 온다.
     }
 }
Пример #2
0
        private void dgvGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // 선택 시 해당품목 이미지 가져오기
            string sIC = dgvGrid.CurrentRow.Cells["ITEMCODE"].Value.ToString();

            connect = new SqlConnection(strCon);
            connect.Open();
            try
            {
                PicItem.Image = null;//이전 이미지를 날리기 위하여. 초기화.

                string sSQL = $"SELECT ITEMIMG FROM TB_TESTITEM_KBS WHERE ITEMCODE = '{sIC}' AND ITEMIMG IS NOT NULL";

                SqlDataAdapter adapter = new SqlDataAdapter(sSQL, connect);
                DataTable      dttemp  = new();
                adapter.Fill(dttemp);
                if (dttemp.Rows.Count == 0)
                {
                    return;
                }
                byte[] bImage = null;
                bImage = (byte[])dttemp.Rows[0]["ITEMIMG"];// 이미지 컬럼의 값을 바이트화한다.
                if (bImage != null)
                {
                    PicItem.Image = new Bitmap(new MemoryStream(bImage)); //메모리스트림을 이용해 파일을 그림 파일로 만든다.
                    PicItem.BringToFront();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                connect.Close();
            }
        }