question

youki avatar image
0 Votes"
youki asked DanielZhang-MSFT commented

Gridview image becomes misshapen below the selected row color

Hello,
I have a png file like in the image below and the the circle becomes misshaping (?!) as you can see.
How can i avoid it?

111573-2021-07-03-22h34-21.png
Regards


dotnet-csharpwindows-forms
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @youki,
In order to find out the cause more quickly and accurately, please provide the relevant code to reproduce the problem.
Best Regards,
Daniel Zhang

0 Votes 0 ·

Hello,
please don't be surprised that i needed a while. I'm still working on it (a lot of things to do in the app). Or maybe it's because there is no border around the circles?


It's the default windows forms gridview and i just use the selectionChanged event.

Loading:

         var list = XML.GetWhatever();

         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].Name == "Test")
             {
                 var green = new Bitmap(Properties.Resources.led_green);
                 green.Tag = "green";
                 gvContent.Rows.Add(green, "Text1", list[i].Description);
             }
             else
             {
                 var red = new Bitmap(Properties.Resources.led_red);
                 red.Tag = "red";
                 gvContent.Rows.Add(red, list[i].Name, list[i].Description);
             }
         }


SelectionChanged

             var dgv = sender as DataGridView;
             var imageCell = dgv.CurrentRow.Cells[0] as DataGridViewImageCell;
             var image = imageCell.Value as Bitmap;

             if (image.Tag.ToString() == "green")
             {
                 lblStatusDescription.Text = "Aktiviert";
             }
             else
             {
                 lblStatusDescription.Text = "Deaktiviert";
             }


Regards

0 Votes 0 ·

Hi @youki,
Have you tried to set the ImageLayout of your picture column to Stretch?
And please provide your "led_green" png file to made a test.
Best Regards,
Daniel Zhang

0 Votes 0 ·

0 Answers