! 제품 버전을 정확하게 입력해 주세요.
제품 버전이 정확하게 기재되어 있지 않은 경우,
최신 버전을 기준으로 안내 드리므로
더욱 빠르고 명확한 안내를 위해
제품 버전을 정확하게 입력해 주세요!

C1FlexGrid 이미지 구현 방법....? > Q&A | 토론

본문 바로가기

ComponentOne

Q&A | 토론

WinForms윈폼 C1FlexGrid 이미지 구현 방법....?

페이지 정보

작성자 뽀록이 작성일 2023-07-23 16:00 조회 465회 댓글 1건
제품 버전 : WinForms Edition 2023V1
컨트롤 이름 : FlexGrid

본문

업무에 수고가 많습니다.


vb.net 2022에서 DataGridView 상에서는 구현을 했는데

WinForms Edition 2023 입문 한지 일주일 밖에 되지 않아


아래 그림에서 처럼 DB에 저장된 파일_1,파일_2,파일_3의 파일명을

FlexGrid에 출력하고 파일 확장장에 맞는 IMG_1,IMG_2,IMG3의 이미지를 

Resources에서 불러 아래와 같이표현하고 싶습니다.

도움을 부탁드립니다.



 

  • 페이스북으로 공유
  • 트위터로  공유
  • 링크 복사
  • 카카오톡으로 보내기

댓글목록

hunahuna님의 댓글

hunahuna 작성일

Bitmap bm = Resources 에서 불러온 이미지

Flexgrid.SetCellimage(row, col, bm);

이렇게 적용하면 될것 같습니다.

2 답변

WinForms윈폼 Re: C1FlexGrid 이미지 구현 방법....?

추천0 이 글을 추천하셨습니다 비추천0

페이지 정보

작성자 GCK폴 작성일 2023-07-25 22:29 댓글 0건

본문

안녕하세요

그레이프시티 입니다.


우선 새롭게 저희 그레이프시티 제품을 사용해 주셔서 감사드립니다.

기본적으로 아래의 페이지를 통해서 데모를 설치하시고 다양한 예제들을 보실수 있습니다.

https://www.grapecity.co.kr/componentone-winform#demo 

여기에는 코드까지 같이 포함되어 있기 때문에 어렵지 않게 적용해 보실수 있을것 같습니다.


이제 셀에 이미지를 추가하는 방법에 대하여 안내해 드리겠습니다.

셀에 이미지를 추가하기 위해서는 아래와 같이 SetCellIamge 방법을 사용하시면 됩니다.


// Set image in cell (3,6)
c1FlexGrid1.SetCellImage(3, 6, Image.FromFile("master.png"));

// Set image in cell range (12,6) to (14, 6)
C1.Win.C1FlexGrid.CellRange cr;
cr = c1FlexGrid1.GetCellRange(12, 6, 14, 6);
cr.Image = Image.FromFile("amex.jpg");

// Display image without text
c1FlexGrid1.Rows[3].ImageAndText = false;


좀더 자세한 설명은 아래의 링크를 참고해 주시기 바랍니다.

https://www.grapecity.com/componentone/docs/win/online-flexgrid/cell-basic-operations.html 


또는 DrawCell을 이용해 직접 이미지를 추가하는 방법도 있습니다.

아래의 예제를 한번 참고해봐 주시기 바랍니다.


public partial class SampleProject: Form
{

    Image img1, img2, img3, img4;// declare member variable

    //Load Event
      private void AuditLogViewer_Load(object sender, EventArgs e)
    {
        object information = Resources.ResourceManager.GetObject("information"); //Return an object from the image chan1.png in the project
        img1 = (Image)information;
        object Warning = Resources.ResourceManager.GetObject("warning"); //Return an object from the image chan1.png in the project
        img2 = (Image)Warning;
        object critical = Resources.ResourceManager.GetObject("critical"); //Return an object from the image chan1.png in the project
        img3 = (Image)critical;
        object unspecified = Resources.ResourceManager.GetObject("unspecified"); //Return an object from the image chan1.png in the project
        img4 = (Image)unspecified;
    }

 //Grid Click Event
    private void grdAuditLogs_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
    {
        if (e.Col == 2)
        {
            //let the grid paint the background and border for the cell
            e.DrawCell(C1.Win.C1FlexGrid.DrawCellFlags.Background | C1.Win.C1FlexGrid.DrawCellFlags.Border);

            //find text width
            var width = (int)e.Graphics.MeasureString(e.Text, e.Style.Font).Width;

            //x-coordinate for each image
            var img1_x = e.Bounds.X + width + 10;
            var img2_x = e.Bounds.X + width + 10;
            var img3_x = e.Bounds.X + width + 10;
            var img4_x = e.Bounds.X + width + 10;

            //var img3_x = img2_x + img2.Width + 5;

            //location for each image
            var img1_loc = new Point(img1_x, e.Bounds.Y + img1.Height - 18);
            var img2_loc = new Point(img2_x, e.Bounds.Y + img2.Height - 18);
            var img3_loc = new Point(img3_x, e.Bounds.Y + img3.Height - 18);
            var img4_loc = new Point(img4_x, e.Bounds.Y + img4.Height - 18);


            //draw images at aforementioned points
            if (grdAuditLogs[e.Row, grdAuditLogs.Cols["Severity"].Index].ToString() == "Information")
                e.Graphics.DrawImage(img1, img1_loc);
            if (grdAuditLogs[e.Row, grdAuditLogs.Cols["Severity"].Index].ToString() == "Warning")
                e.Graphics.DrawImage(img2, img2_loc);
            if (grdAuditLogs[e.Row, grdAuditLogs.Cols["Severity"].Index].ToString() == "Critical")
                e.Graphics.DrawImage(img3, img3_loc);
            if (grdAuditLogs[e.Row, grdAuditLogs.Cols["Severity"].Index].ToString() == "Unspecified")
                e.Graphics.DrawImage(img4, img4_loc);

            //e1.Graphics.DrawImage(img3, img3_loc);

            //draw text
            e.Graphics.DrawString(e.Text, e.Style.Font, Brushes.Black, e.Bounds.Location);
            e.Handled = true;
        }
    }



추가적으로 궁금하신 사항은 다시 문의해 주시기 바랍니다.

감사합니다.

그레이프시티 드림.

댓글목록

등록된 댓글이 없습니다.

WinForms윈폼 Re: C1FlexGrid 이미지 구현 방법....?

추천0 이 글을 추천하셨습니다 비추천0

페이지 정보

작성자 GCK싸이먼 작성일 2023-07-26 16:35 댓글 0건

본문

첨부파일

안녕하세요

그레이프시티입니다.


추가적으로 고객님께서 참고하실 수 있는 샘플 프로젝트를 첨부드립니다.

프로젝트를 참고하시면 원하시는 기능 구현에 도움이 될 것입니다. 


추가로 궁금하신 사항은 문의해 주시기 바랍니다.

감사합니다.

그레이프시티 드림.

댓글목록

등록된 댓글이 없습니다.

메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
이메일 : sales-kor@mescius.com | 전화 : 1670-0583 | 경기도 과천시 과천대로 7길 33, 디테크타워 B동 1107호 메시어스(주) 대표자 : 허경명 | 사업자등록번호 : 123-84-00981 | 통신판매업신고번호 : 2013-경기안양-00331 ⓒ 2024 MESCIUS inc. All rights reserved.