<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WinForms</title><link>https://www.dotnetzone.gr:443/cs/forums/12/ShowForum.aspx</link><description>Θέματα για rich client / windows εφαρμογές, σε οποιαδήποτε γλώσσα (VB.NET, C#, managed C++, κ.α.)</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: DataGridViewColumn και DataGridViewImageColumn</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/61296.aspx</link><pubDate>Sun, 05 Dec 2010 02:24:41 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:61296</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/61296.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=12&amp;PostID=61296</wfw:commentRss><description>&lt;P&gt;Ο σωστός και εύκολος τρόπος να ελέγχεις τον τύπο μίας μεταβλητής είναι το is ή το as. Μπορείς π.χ. να γράψεις if (column is DataGridViewColumn) και μετά να κάνεις το cast, ή να κάνεις απευθείας το cast με το as και μετά να ελέγξεις αν το αποτέλεσμα είναι null και να προχωρήσεις:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;forach (var column &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;in&lt;/SPAN&gt; dgv.Columns)
{
    var imageColumn=column &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;as&lt;/SPAN&gt; DataGridViewImageColumn;
    imageColumn.ImageLayout=...
}&lt;/SPAN&gt;&lt;/PRE&gt;</description></item><item><title>Απ: DataGridViewColumn και DataGridViewImageColumn</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/61283.aspx</link><pubDate>Sat, 04 Dec 2010 22:39:19 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:61283</guid><dc:creator>evliatsas</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/61283.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=12&amp;PostID=61283</wfw:commentRss><description>&lt;P&gt;Ο έλεγχος με τον τύπο της στήλης είναι σχετικά απλός, π.χ.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;foreach&lt;/SPAN&gt; (DataGridViewColumn column &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;in&lt;/SPAN&gt; dgv.Columns)
{ 
     &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;if&lt;/SPAN&gt;(Type.Equals(column.GetType(),&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:blue;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;typeof&lt;/SPAN&gt;(DataGridViewImageColumn)))
     {
        DataGridViewImageColumn dtgvic &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:red;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;=&lt;/SPAN&gt; (DataGridViewImageColumn)column;
        dtgvic.ImageLayout &lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:red;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;=&lt;/SPAN&gt; DataGridViewImageCellLayout.Stretch;
      }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;FONT size=2 face=Tahoma&gt;Ωστόσο το cast της στήλης δεν νομίζω ότι μπορείς να το αποφύγεις, αφού το Property ImageLayout είναι type specific&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="BACKGROUND-COLOR:transparent;FONT-FAMILY:Courier New;COLOR:black;FONT-SIZE:11px;FONT-WEIGHT:normal;"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;</description></item><item><title>DataGridViewColumn και DataGridViewImageColumn</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/59840.aspx</link><pubDate>Wed, 01 Sep 2010 04:49:02 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:59840</guid><dc:creator>sakis_drm</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/59840.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=12&amp;PostID=59840</wfw:commentRss><description>Καλησπέρα σε ολους.&lt;br&gt;&lt;br&gt;Σε ένα datagridView που δείχνει τα αποτελέσματα ενός sql ερωτήματος το οποίο περιέχει εικόνες. π.χ. :&lt;br&gt;&lt;br&gt;SELECT [ID_Person], [Name], [&lt;b&gt;Img&lt;/b&gt;] FROM [Persons]&lt;br&gt;&lt;br&gt;Προσπαθώ να βρώ έναν ωραίο τρόπο, ώστε οι εικόνες που δείχνει να γίνονται strech, για να φαίνονται ως μικρογραφίες στο ύψος που επιτρέπει μια φυσιολογική μικρή γραμμή ενός grid.&lt;br&gt;&lt;br&gt;Για παράδειγμα, όπως με αυτόν τον τρόπο τρέχω μια μια τις στήλες για να κόψω το sort :&lt;br&gt;&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tr style="vertical-align:top;line-height:normal;"&gt;&lt;td style="width:40px;text-align:right;"&gt;&lt;pre style="font-family:courier new;font-size:11px;color:gray;margin:0px;padding:2px;"&gt;1
2
3
4
 &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style="margin:0px;padding:2px 2px 2px 8px;"&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;   &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;foreach&lt;/span&gt; (DataGridViewColumn column &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; dgv.Columns)
   {
       column.SortMode &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; DataGridViewColumnSortMode.NotSortable;
   }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;Θα βόλευε αν το παραπάνω μπορούσε να επεκταθεί σε :&lt;br&gt;&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tr style="vertical-align:top;line-height:normal;"&gt;&lt;td style="width:40px;text-align:right;"&gt;&lt;pre style="font-family:courier new;font-size:11px;color:gray;margin:0px;padding:2px;"&gt;1
2
3
4
5
 &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style="margin:0px;padding:2px 2px 2px 8px;"&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;    foreach&lt;/span&gt; (DataGridViewColumn column &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; dgv.Columns)&lt;br&gt;    {&lt;br&gt;        column.SortMode &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; DataGridViewColumnSortMode.NotSortable;&lt;br&gt;        &lt;b&gt;column.&lt;font color="#ff0000"&gt;ImageLayout &lt;/font&gt;&lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; DataGridViewImageCellLayout.Stretch;&lt;/b&gt;&lt;br&gt;    }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;όμως το &lt;font color="#ff0000"&gt;ImageLayout &lt;/font&gt;κοκκινίζει γιατί δεν αποτελεί υπαρκτό property.&lt;br&gt;&lt;br&gt;Άρα πάμε στο αντικέιμενο DataGridView&lt;b&gt;Image&lt;/b&gt;Column :&lt;br&gt;&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tr style="vertical-align:top;line-height:normal;"&gt;&lt;td style="width:40px;text-align:right;"&gt;&lt;pre style="font-family:courier new;font-size:11px;color:gray;margin:0px;padding:2px;"&gt;1
2
3
4
 &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style="margin:0px;padding:2px 2px 2px 8px;"&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;foreach&lt;/span&gt; (DataGridViewImageColumn column &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; dgv.Columns)
    {
        column.ImageLayout &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; DataGridViewImageCellLayout.Stretch;
    }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;Το οποίο χτυπάει ότι δεν μπορεί να κάνει cast το DataGridViewTextBoxColumn σε DataGridViewImageColumn.&lt;br&gt;&lt;br&gt;Τελικά κατέληξα στο άσχημο :&lt;br&gt;&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tr style="vertical-align:top;line-height:normal;"&gt;&lt;td style="width:40px;text-align:right;"&gt;&lt;pre style="font-family:courier new;font-size:11px;color:gray;margin:0px;padding:2px;"&gt;1
2
3
4
5
6
7
8
9
 &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style="margin:0px;padding:2px 2px 2px 8px;"&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;    foreach&lt;/span&gt; (DataGridViewColumn column &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; dgv.Columns)
    {
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;if&lt;/span&gt; (column.Name == &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Img"&lt;/span&gt;)
        {
            DataGridViewImageColumn dtgvic &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt; DataGridViewImageColumn();
            dtgvic &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; (DataGridViewImageColumn) column;
            dtgvic.ImageLayout &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; DataGridViewImageCellLayout.Stretch;
        }
    }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;Υπαρχει κάποιος καλύτερος τρόπος από τον έλεγχο του ονόματος της στήλης? Π.χ. να ελέγχεται ο τύπος της στήλης ότι είναι εικόνας?&lt;br&gt;Δοκίμασα με την typeof και την GetType() αλλά δεν κατάφερα γιατί πάλι έχω το θέμα με το cast από το ένα στο άλλο.&lt;br&gt;</description></item></channel></rss>