<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ユーザーコントロール | 株式会社ファーストペンギン</title>
	<atom:link href="https://www.firstpenguin.co.jp/tag/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%AB/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.firstpenguin.co.jp</link>
	<description></description>
	<lastBuildDate>Mon, 15 Jun 2020 11:07:30 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.firstpenguin.co.jp/wp-content/uploads/2019/09/cropped-icon-32x32.png</url>
	<title>ユーザーコントロール | 株式会社ファーストペンギン</title>
	<link>https://www.firstpenguin.co.jp</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/>
<atom:link rel="hub" href="https://websubhub.com/hub"/>
<atom:link rel="self" href="https://www.firstpenguin.co.jp/tag/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%AB/feed/"/>
	<item>
		<title>C# ユーザーコントロールを配置する時の注意点</title>
		<link>https://www.firstpenguin.co.jp/c-usercontrol-1/</link>
					<comments>https://www.firstpenguin.co.jp/c-usercontrol-1/#respond</comments>
		
		<dc:creator><![CDATA[takashima.kentaro]]></dc:creator>
		<pubDate>Mon, 15 Jun 2020 11:07:53 +0000</pubDate>
				<category><![CDATA[技術情報]]></category>
		<category><![CDATA[開発]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ユーザーコントロール]]></category>
		<category><![CDATA[フォントサイズ]]></category>
		<category><![CDATA[AutoScaleMode]]></category>
		<guid isPermaLink="false">https://www.firstpenguin.co.jp/?p=319</guid>

					<description><![CDATA[今回はユーザーコントロールを配置した時に少し躓いた点について紹介します。 以下のようなユーザコントロールを作成しました。 メインのフォームに配置してみると、何度やってもコントロールの位置やフォントサイズがおかしくなります [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>今回はユーザーコントロールを配置した時に少し躓いた点について紹介します。</p>
<p>以下のようなユーザコントロールを作成しました。<br />
<img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-322" src="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1.png" alt="" width="735" height="413" srcset="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1.png 735w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1-300x169.png 300w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1-120x68.png 120w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1-160x90.png 160w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1-320x180.png 320w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-1-406x228.png 406w" sizes="(max-width: 735px) 100vw, 735px" /></p>
<p>メインのフォームに配置してみると、何度やってもコントロールの位置やフォントサイズがおかしくなります。<br />
<img decoding="async" class="alignnone size-full wp-image-323" src="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-2.png" alt="" width="735" height="537" srcset="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-2.png 735w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-2-300x219.png 300w" sizes="(max-width: 735px) 100vw, 735px" /></p>
<p>配置したユーザーコントロールのプロパティ(AutoSizeなど)を確認してもおかしくなる理由が見つからず、作り直してまた配置してみようかと思い始めました。</p>
<p>もう一度プロパティの設定を確認してみようと、先ほどとは違いユーザーコントロールをデザイナで開きプロパティを一つ一つ確認していくと、<br />
<img decoding="async" class="alignnone size-full wp-image-325" src="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-3.png" alt="" width="782" height="426" srcset="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-3.png 782w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-3-300x163.png 300w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-3-768x418.png 768w" sizes="(max-width: 782px) 100vw, 782px" /></p>
<div class="info-box">「AutoScaleMode」</div>
<p>なるものを発見。説明文を見てみると、</p>
<div class="info-box">解像度またはフォントが変更されたとき、フォームまたはコントロールのサイズ変更方法を決定します。</div>
<p>と書かれていました。<br />
設定するAutoScaleMode定数を見てみると、</p>
<div class="hcb_wrap blank-box">
<pre class="prism line-numbers lang-csharp" data-lang="C#"><code>//
// 概要:
// 自動スケーリングが無効になっています。
None = 0,
//
// 概要:
// クラスが使用するフォント (通常はシステム フォント) のサイズに応じてスケールを制御します。
Font = 1,
//
// 概要:
// ディスプレイの解像度に応じてスケールを制御します。 一般的な解像度は 96 dpi と 120 dpi です。
Dpi = 2,
//
// 概要:
// クラスの親のスケーリング モードに従ってスケールを制御します。 親が存在しない場合、自動スケーリングは無効になっています。
Inherit = 3</code></pre>
</div>
<p>初期値では「Font」が設定されていたため、「None」を設定し再コンパイル。<br />
メインのフォームをデザイナで開いてみると、無事ユーザーコントロールを作成した通りの見た目で配置することが出来ました。<br />
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-326" src="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-4.png" alt="" width="785" height="521" srcset="https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-4.png 785w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-4-300x199.png 300w, https://www.firstpenguin.co.jp/wp-content/uploads/c-usercontrol-4-768x510.png 768w" sizes="(max-width: 785px) 100vw, 785px" /></p>
<div class="alert-box">原因となっていたのは、配置先であるメインフォームのフォントを変更していたためでした。<br />
AutoScaleModeプロパティで「Font」が設定されていると配置先のフォントに合わせて自動でスケーリングされるようです。</div>
<p>もし同じような現象が起きて困ったら、参考に設定を見直してみてください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.firstpenguin.co.jp/c-usercontrol-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
