{"id":10035,"date":"2019-04-24T19:17:54","date_gmt":"2019-04-24T10:17:54","guid":{"rendered":"https:\/\/elleneast.com\/?p=10035"},"modified":"2019-04-24T19:28:08","modified_gmt":"2019-04-24T10:28:08","slug":"%e3%80%90wpf%e3%80%91listview-%e3%81%ae%e5%88%97%e3%83%98%e3%83%83%e3%83%80%e3%83%bc%e3%81%ae%e9%a0%86%e5%ba%8f%e3%81%a8%e5%b9%85%e3%82%92%e4%bf%9d%e5%ad%98%e3%83%bb%e5%be%a9%e5%85%83","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=10035","title":{"rendered":"\u3010WPF\u3011ListView \u306e\u5217\u30d8\u30c3\u30c0\u30fc\u306e\u9806\u5e8f\u3068\u5e45\u3092\u4fdd\u5b58\u30fb\u5fa9\u5143"},"content":{"rendered":"<p>ListView \u306e\u5217\u30d8\u30c3\u30c0\u30fc\u306e\u9806\u5e8f\u3068\u5e45\u3092\u4fdd\u5b58\u30fb\u5fa9\u5143\u3059\u308b\u3084\u308a\u65b9\u3067\u3059\u3002<\/p>\n<div class=\"memo \">\n<div class=\"memo_ttl dfont\"> MEMO<\/div>\n<p>WPF \u306e ListView \u306e\u8a71\u984c\u3067\u3059\u3002Forms \u306e ListView \u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n<p>\u305f\u3068\u3048\u3070\u3053\u3093\u306a xaml \u306e\u5834\u5408\u3002<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;ListView&gt;\n&lt;ListView.View&gt;\n&lt;GridView&gt;\n\n    &lt;GridViewColumn Width=\"50\"&gt;\n        &lt;GridViewColumnHeader Content=\"\u6709\u52b9\" \/&gt;\n            &lt;GridViewColumn.CellTemplate&gt;\n                &lt;DataTemplate&gt;\n                    &lt;CheckBox IsChecked=\"{Binding IsEnabled}\" \/&gt;\n                &lt;\/DataTemplate&gt;\n        &lt;\/GridViewColumn.CellTemplate&gt;\n    &lt;\/GridViewColumn&gt;\n\n    &lt;GridViewColumn Width=\"250\" DisplayMemberBinding=\"{Binding MailAddress}\"&gt;\n        &lt;GridViewColumnHeader Content=\"\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\" \/&gt;\n    &lt;\/GridViewColumn&gt;\n    \n    &lt;GridViewColumn Width=\"100\"&gt;\n        &lt;GridViewColumnHeader Content=\"\u30e1\u30e2\" \/&gt;\n            &lt;GridViewColumn.CellTemplate&gt;\n                &lt;DataTemplate&gt;\n                    &lt;TextBlock Text=\"{Binding Memo}\" \/&gt;\n                &lt;\/DataTemplate&gt;\n        &lt;\/GridViewColumn.CellTemplate&gt;\n    &lt;\/GridViewColumn&gt;\n\n&lt;\/GridView&gt;\n&lt;\/ListView.View&gt;\n&lt;\/ListView&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u30c0\u30a4\u30a2\u30ed\u30b0\u306e\u30a4\u30e1\u30fc\u30b8\u306f\u3053\u3093\u306a\u611f\u3058\u3002\uff08\u898b\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b\u3001xaml \u306e\u307b\u3046\u304b\u3089\u306f\u30bf\u30b0\u3092\u3044\u308d\u3044\u308d\u7701\u7565\u3057\u3066\u3042\u308a\u307e\u3059\uff09<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ListViewColOrderAndWidth_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10040 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ListViewColOrderAndWidth_1.png\" alt=\"\" width=\"355\" height=\"92\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ListViewColOrderAndWidth_1.png 355w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/ListViewColOrderAndWidth_1-300x78.png 300w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u5217\u9806\u3068\u5217\u5e45\u306e\u53d6\u5f97\uff08\u4fdd\u5b58\uff09\u306e\u30b3\u30fc\u30c9\u3002<\/p>\n<pre class=\"lang:vbnet decode:true\">Dim oGridView As GridView = oListView.View\nDim oCols As GridViewColumnCollection = oGridView.Columns\n\nFor Each oCol As GridViewColumn In oCols\n    '\u5404\u5217\u306e\u540d\u524d\u3068\u5e45\u3092\u597d\u304d\u306a\u3088\u3046\u306b\u4fdd\u5b58\u2193\n    'DirectCast(oCol.Header, GridViewColumnHeader).Content.ToString\n    'oCol.Width.ToString\nNext<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5217\u9806\u3068\u5217\u5e45\u306e\u5fa9\u5143\u306e\u30b3\u30fc\u30c9\u3002<\/p>\n<pre class=\"lang:vbnet decode:true\">Dim oGridView As GridView = oListView.View\nDim oCols As GridViewColumnCollection = oGridView.Columns\n\nDim IndexAfter As Integer = 0\nFor Each ColInfoArray As String() In ColNameWidthList '\u2190 \u4fdd\u5b58\u3057\u3066\u304a\u3044\u305f\u5217\u540d\u30fb\u5217\u5e45\u306e\u30ea\u30b9\u30c8\u3084\u914d\u5217\n    Dim ColName As String = ColInfoArray(0)\n    Dim ColWidth As Integer = ColInfoArray(1)\n    '\u3053\u306e\u3078\u3093\u2191\u306f\u597d\u304d\u306a\u3084\u308a\u65b9\u3067\u3002\n\n    Dim bFound As Boolean = False\n    Dim IndexBefore As Integer = 0\n    For i As Integer = IndexAfter To oCols.Count -1\n        Dim oCol As GridViewColumn = oCols(i)\n        if DirectCast(oCol.Header, GridViewColumnHeader).Content.ToString().Equals(ColName) Then\n            bFound = True\n            IndexBefore = i\n            oCol.Width = ColWidth\n            Exit For\n        End If\n    Next\n    If bFound = True Then\n        oCols.Move(IndexBefore, IndexAfter)\n        IndexAfter += 1\n    End If\nNext<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ListView \u306e\u5217\u30d8\u30c3\u30c0\u30fc\u306e\u9806\u5e8f\u3068\u5e45\u3092\u4fdd\u5b58\u30fb\u5fa9\u5143\u3059\u308b\u3084\u308a\u65b9\u3067\u3059\u3002 \u305f\u3068\u3048\u3070\u3053\u3093\u306a xaml \u306e\u5834\u5408\u3002 &lt;ListView&gt; &lt;ListView.View&gt; &lt;GridView&gt; &#038; &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2656,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[57],"tags":[62],"class_list":{"0":"post-10035","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-57","8":"tag-wpf"},"_links":{"self":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/10035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10035"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/10035\/revisions"}],"predecessor-version":[{"id":10048,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/10035\/revisions\/10048"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/media\/2656"}],"wp:attachment":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}