'X座標を取得する
Dim x As Integer = System.Windows.Forms.Cursor.Position.X
'Y座標を取得する
Dim y As Integer = System.Windows.Forms.Cursor.Position.Y
System.Windows.Forms.Cursor.Position = New System.Drawing.Point(0, 0)
'矢印
Cursor.Current = Cursors.Arrow
'処理中
Cursor.Current = Cursors.WaitCursor
'不可
Cursor.Current = Cursors.No
Button1.Width = 200
Button1.Height = 34
Button1.FlatStyle = FlatStyle.Flat
Button1.FlatStyle = FlatStyle.Popup
Button1.FlatStyle = FlatStyle.Standard
Button1.FlatStyle = FlatStyle.System
Button1.TextAlign = ContentAlignment.TopLeft
Button1.TextAlign = ContentAlignment.TopCenter
Button1.TextAlign = ContentAlignment.TopRight
Button1.TextAlign = ContentAlignment.MiddleLeft
Button1.TextAlign = ContentAlignment.MiddleCenter
Button1.TextAlign = ContentAlignment.MiddleRight
Button1.TextAlign = ContentAlignment.BottomLeft
Button1.TextAlign = ContentAlignment.BottomCenter
Button1.TextAlign = ContentAlignment.BottomRight
Button1.ForeColor = System.Drawing.Color.White
Button1.AutoSize = False
Button1.AutoEllipsis = True
Button1.BackColor=Color.Yellow
Button1.Image = System.Drawing.Image.FromFile("C:\BackImg.jpg")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
Button1.PerformClick()
If CheckBox1.Checked = True Then
MessageBox.Show("チェックされています。")
Else
MessageBox.Show("チェックされていません。")
End If
ComboBox1.Items.Count()
CheckBox1.CheckAlign = ContentAlignment.TopLeft
CheckBox1.CheckAlign = ContentAlignment.TopCenter
CheckBox1.CheckAlign = ContentAlignment.TopRight
CheckBox1.CheckAlign = ContentAlignment.MiddleLeft
CheckBox1.CheckAlign = ContentAlignment.MiddleCenter
CheckBox1.CheckAlign = ContentAlignment.MiddleRight
CheckBox1.CheckAlign = ContentAlignment.BottomLeft
CheckBox1.CheckAlign = ContentAlignment.BottomCenter
CheckBox1.CheckAlign = ContentAlignment.BottomRight
CheckedListBox1.Items.Add("値")
または
Dim strData() As String = {"値1", "値2", "値3", "値4", "値5"}
CheckedListBox1.Items.AddRange(strData)
'選択された状態
CheckedListBox1.Items.Add("値1", True)
'選択されてない状態
CheckedListBox1.Items.Add("値2", False)
CheckedListBox1.Items.Remove("値1")
または
CheckedListBox1.Items.RemoveAt(0)
CheckedListBox1.SetSelected(0, True)
CheckedListBox1.Items.Count
If CheckedListBox1.GetItemChecked(0) = True Then
End If
CheckedListBox1.CheckedItems.Count.ToString()
If CheckedListBox1.GetSelected(0) = True Then
End If
CheckedListBox1.HorizontalScrollbar = True
ComboBox1.Items.Add("値1")
または
Dim strData() As String = {"値1", "値2", "値3", "値4", "値5"}
ComboBox1.Items.AddRange(strData)
または
ComboBox1.Items.Insert(3, "値x")
ComboBox1.Items.Remove("値1")
または
ComboBox1.Items.RemoveAt(0)
ComboBox1.Items.Count()
ComboBox1.SelectedIndex = 2
または
ComboBox1.Value = "値1"
ComboBox1.SelectedIndex
ComboBox1.MaxDropDownItems = 10
ComboBox1.DropDownWidth = 100
'2021年 7月25日 のように漢字で表示します
DateTimePicker1.Format = DateTimePickerFormat.Long
'年,月,日をスラッシュで区切った形式で表示します
DateTimePicker2.Format = DateTimePickerFormat.Short
'時刻を表示します
DateTimePicker3.Format = DateTimePickerFormat.Time
'yyyy/MM/dd HH:mm:ss
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "yyyy/MM/dd HH:mm:ss"
'yyyy年MM月dd日 HH時mm分ss秒
DateTimePicker3.Format = DateTimePickerFormat.Custom
DateTimePicker3.CustomFormat = "yyyy年MM月dd日 HH時mm分ss秒"
'MM/dd/yyyy HH:mm:ss
DateTimePicker2.Format = DateTimePickerFormat.Custom
DateTimePicker2.CustomFormat = "MM/dd/yyyy HH:mm:ss"
'指定可能最小日時を設定(1980/01/01 0:00:00)
DateTimePicker1.MinDate = New DateTime(1980, 1, 1, 0, 0, 0)
'指定可能最大日時を設定(2021/12/31 23:59:59)
DateTimePicker1.MaxDate = New DateTime(2021, 12, 31, 23, 59, 59)
Label1.Text = "テキスト"
'上段左端
Label1.TextAlign = ContentAlignment.TopLeft
'上段中央
Label1.TextAlign = ContentAlignment.TopCenter
'上段右端
Label1.TextAlign = ContentAlignment.TopRight
'中段左端
Label1.TextAlign = ContentAlignment.MiddleLeft
'中段中央
Label1.TextAlign = ContentAlignment.MiddleCenter
'中段右端
Label1.TextAlign = ContentAlignment.MiddleRight
'下段左端
Label1.TextAlign = ContentAlignment.BottomLeft
'下段中央
Label1.TextAlign = ContentAlignment.BottomCenter
'下段右端
Label1.TextAlign = ContentAlignment.BottomRight
'表示する文字列の設定
LinkLabel1.Text = "Yahoo! JAPAN"
'表示する文字列とリンク先を関連づける
LinkLabel1.Links.Add(0, LinkLabel1.Text.Length, "https://www.yahoo.co.jp/")
Process.Start(LinkLabel1.Links(0).LinkData.ToString())
LinkLabel1.LinkColor = Color.Black
LinkLabel2.VisitedLinkColor = Color.Purple
LinkLabel2.LinkVisited = True
LinkLabel1.Font = New Font(LinkLabel1.Font, FontStyle.Bold)
ListBox1.Items.Add("値1")
または
Dim strData() As String = {"値1", "値2", "値3", "値4", "値5"}
ListBox1.Items.AddRange(strData)
または
ListBox1.Items.Insert(3, "値x")
ListBox1.Items.Remove("値1")
または
ListBox1.Items.RemoveAt(0)
ListBox1.HorizontalScrollbar = True
ListBox1.Items.Count
ListBox1.SetSelected(3, True)
ListBox1.SelectionMode = SelectionMode.MultiExtended
ListBox1.SetSelected(0,True)
ListBox1.ClearSelected()
If ListBox1.GetSelected(2) = True Then
End If
'LargeIcon
ListView1.View = View.LargeIcon
'Details
ListView1.View = View.Details
'SmallIcon
ListView1.View = View.SmallIcon
'List
ListView1.View = View.List
'Title
ListView1.View = View.Tile
'詳細表示にする
ListView1.View = View.Details
'ヘッダーを追加する(ヘッダー名、幅、アライメント)
ListView1.Columns.Add("ヘッダー名", 100, HorizontalAlignment.Left)
'アイテムの作成(1列目)
itemx.Text = "ヘッダーの値"
'アイテムの追加(2列目以降)
itemx.SubItems.Add("値1") 'サブアイテムの追加
itemx.SubItems.Add("値2") 'サブアイテムの追加
'アイテムをリスビューに追加する
ListView1.Items.Add(itemx)
ListView1.Items.Remove(0)
ListView1.Clear()
ListView1.Items.Count
ListView1.SelectedItems.Count
'1番目に選択されれいるアイテムをitemxに格納
itemx = ListView1.SelectedItems(0)
'選択されているアイテムを取得する
Dim msg As String
msg = "1列目 " & itemx.Text & vbCrLf
msg &= "2列目 " & itemx.SubItems(1).Text & vbCrLf
msg &= "3列目 " & itemx.SubItems(2).Text
ListView1.GridLines = True
ListView1.CheckBoxes = True
ListView1.Items(0).BackColor = Color.Yellow
'携帯電話番号
MaskedTextBox1.Mask = "000-0000-0000"
MaskedTextBox1.AsciiOnly = True
'無効な文字が入力された場合にBeep音を鳴らす
MaskedTextBox1.BeepOnError = True
'マスクに数値3桁を設定
MaskedTextBox1.Mask = "000"
'※この場合、数字以外または4桁以上の入力でBeep音が鳴ります。
MaskedTextBox1.HidePromptOnLeave = True
'キーボードの現在のInsモードに従います
MaskedTextBox1.InsertKeyMode = InsertKeyMode.Default
'挿入モードを有効にする
MaskedTextBox1.InsertKeyMode = InsertKeyMode.Insert
'上書きモードを有効にする
MaskedTextBox1.InsertKeyMode = InsertKeyMode.Overwrite
MaskedTextBox1.PasswordChar = "*"
MaskedTextBox1.PromptChar = "-"
MaskedTextBox1.ReadOnly = True
Private Sub MaskedTextBox1_MaskInputRejected( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles MaskedTextBox1.MaskInputRejected
MessageBox.Show("無効な文字が入力されました。")
End Sub
MonthCalendar1.ShowToday = Not MonthCalendar1.ShowToday
MonthCalendar1.ShowTodayCircle = Not MonthCalendar1.ShowTodayCircle
MonthCalendar1.ShowWeekNumbers = Not MonthCalendar1.ShowWeekNumbers
MonthCalendar1.MaxSelectionCount = 7
MonthCalendar1.SelectionStart.ToString()
MonthCalendar1.SelectionEnd.ToString()
'選択可能最小日時を1980/01/01 0:00:00 を指定
MonthCalendar1.MinDate = New System.DateTime(1980, 1, 1, 0, 0, 0, 0)
'選択可能最大日時を2021/12/31 23:59:59 を指定
MonthCalendar1.MaxDate = New System.DateTime(2021, 12, 31, 23, 59, 59, 0)
MonthCalendar1.FirstDayOfWeek = Day.Tuesday
MonthCalendar1.CalendarDimensions = New Size(3, 2)
'タスクトレイに表示するアイコンを設定する
Dim ico As New System.Drawing.Icon("C:\icon.ico")
NotifyIcon1.Icon = ico
'タスクトレイにアイコンを表示する
NotifyIcon1.Visible = True
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
'フォームを非表示にする
Me.Visible = False
'タスクトレイに表示するアイコンを設定する
Dim ico As New System.Drawing.Icon("C:\icon.ico")
NotifyIcon1.Icon = ico
'タスクトレイにアイコンを表示する
NotifyIcon1.Visible = True
End If
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
'フォームを表示する
Me.Visible = True
If Me.WindowState = FormWindowState.Minimized Then
'ノーマルウィンドウに戻す
Me.WindowState = FormWindowState.Normal
'アクティブにする
Me.Activate()
'タスクトレイからアイコンを削除する
NotifyIcon1.Visible = False
End If
End Sub
NotifyIcon1.Text = "テキスト"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Error
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(2000, "Error", "This is the text", ToolTipIcon.Error)
'Info
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(2000, "Info", "This is the text", ToolTipIcon.Info)
'None
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(2000, "None", "This is the text", ToolTipIcon.None)
'Warning
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(2000, "Warning", "This is the text", ToolTipIcon.Warning)
'最小値を指定する
NumericUpDown1.Minimum = -100
'最大値を指定する
NumericUpDown1.Maximum = 100
'移動量を5にする
NumericUpDown1.Increment = 5
'小数点第2位まで表示できるようにする
NumericUpDown1.DecimalPlaces = 2
'小数点を表示してみる
NumericUpDown1.Value = 3.15
NumericUpDown1.ThousandsSeparator = True
NumericUpDown1.Hexadecimal = True
NumericUpDown1.UpDownAlign = LeftRightAlignment.Left
'値を増分する
NumericUpDown1.UpButton()
'値を減分する
NumericUpDown1.DownButton()
PictureBox1.Image = Image.FromFile("C:\Image.jpg")
'枠のサイズに合わせて画像を表示
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
'元の画像サイズを基準に、画像の中央部分が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
'枠の左上を基準に画像が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
'枠のサイズで画像が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
'画像のサイズ比を基準に拡大、縮小表示される
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
'枠のサイズに合わせて画像を表示
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
'元の画像サイズを基準に、画像の中央部分が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
'枠の左上を基準に画像が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
'枠のサイズで画像が表示される
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
'画像のサイズ比を基準に拡大、縮小表示される
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
Dim bmp As New Bitmap(PictureBox1.Image, PictureBox1.Width * 0.5, PictureBox1.Height * 0.5)
PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
PictureBox1.Refresh()
'Rotate180FlipNone:反転せずに 180 度回転する。
'Rotate180FlipX:180 度回転してから、水平方向に反転する
'Rotate180FlipXY:180 度回転してから、水平方向と垂直方向に反転する
'Rotate180FlipY:180 度回転してから、垂直方向に反転する
'Rotate270FlipNone:反転せずに 270 度回転する
'Rotate270FlipX:270 度回転してから、水平方向に反転する
'Rotate270FlipXY:270 度回転してから、水平方向と垂直方向に反転する
'Rotate270FlipY:270 度回転してから、垂直方向に反転する
'Rotate90FlipNone:反転せずに 90 度回転する
'Rotate90FlipX:90 度回転してから、水平方向に反転する
'Rotate90FlipXY:90 度回転してから、水平方向と垂直方向に反転する
'Rotate90FlipY:90 度回転してから、垂直方向に反転する
'RotateNoneFlipNone:回転も反転も行わない
'RotateNoneFlipX:回転せずに水平方向に反転する
'RotateNoneFlipXY:回転せずに水平方向と垂直方向に反転する
'RotateNoneFlipY:回転せずに垂直方向に反転する
PictureBox1.Image.Save("C:\Image.jpg", Imaging.ImageFormat.Jpeg)
PictureBox1.Image = CType(Clipboard.GetDataObject().GetData(DataFormats.Bitmap), Bitmap)
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.value = 50
または
ProgressBar1.Step = 2
ProgressBar1.Style = ProgressBarStyle.Blocks
ProgressBar1.Style = ProgressBarStyle.Continuous
ProgressBar1.Style = ProgressBarStyle.Marquee
'アニメーションスピード
ProgressBar1.MarqueeAnimationSpeed = 100
RadioButton1.Appearance = Appearance.Button
RadioButton1.AutoSize = False
RadioButton1.AutoEllipsis = True
RadioButton1.CheckAlign = ContentAlignment.TopLeft
RadioButton2.CheckAlign = ContentAlignment.TopCenter
RadioButton3.CheckAlign = ContentAlignment.TopRight
RadioButton4.CheckAlign = ContentAlignment.MiddleLeft
RadioButton5.CheckAlign = ContentAlignment.MiddleCenter
RadioButton6.CheckAlign = ContentAlignment.MiddleRight
RadioButton7.CheckAlign = ContentAlignment.BottomLeft
RadioButton8.CheckAlign = ContentAlignment.BottomCenter
RadioButton9.CheckAlign = ContentAlignment.BottomRight
RichTextBox1.LoadFile("C:\Test.txt", RichTextBoxStreamType.PlainText)
RichTextBox1.SaveFile("C:\Test.txt", RichTextBoxStreamType.PlainText)
または、リッチテキストとして保存する場合は
RichTextBox1.SaveFile("C:\Test.rtf", RichTextBoxStreamType.RichText)
RichTextBox1.Lines.Length.ToString()
RichTextBox1.SelectionColor = Color.Red
RichTextBox1.SelectionBackColor = Color.Red
RichTextBox1.SelectionFont = New Font("MS ゴシック", 12, FontStyle.Bold)
RichTextBox1.Select(5, 10)
RichTextBox1.HideSelection = False
RichTextBox1.SelectionStart.ToString()
RichTextBox1.DetectUrls = True
TextBox1.ReadOnly = True
TextBox1.SelectAll()
TextBox1.PasswordChar = "*"
TextBox1.Multiline = True
TextBox1.WordWrap = True
TextBox1.AcceptsTab = True
Dim toolTipMsg As New ToolTip
toolTipMsg.SetToolTip(TextBox1, "テスト")
※この方法よりもToolTipを追加したのち、各プロパティに直接記述した方が簡単です。
toolTipMsg.Active = Not toolTipMsg.Active
toolTipMsg.ToolTipTitle = "タイトル"
toolTipMsg.IsBalloon = True
toolTipMsg.ToolTipIcon = ToolTipIcon.None
toolTipMsg.ToolTipIcon = ToolTipIcon.Info
toolTipMsg.ToolTipIcon = ToolTipIcon.Error
toolTipMsg.ToolTipIcon = ToolTipIcon.Warning
toolTipMsg.InitialDelay = 5
toolTipMsDim rootNode As New TreeNode
rootNode.Text = "ルート"
toolTipMsDim rootNode As New TreeNode
rootNode.Text = "ルート"
Dim childNode1 As New TreeNode
childNode1.Text = "子ノード1"
rootNode.Nodes.Add(childNode1)
toolTipMsDim rootNode As New TreeNode
rootNode.Text = "ルート"
Dim childNode1 As New TreeNode
childNode1.Text = "子ノード1"
rootNode.Nodes.Add(childNode1)
Dim grandChildNode1 As New TreeNode
grandChildNode1.Text = "孫ノード1"
childNode1.Nodes.Add(grandChildNode1)
Dim SelectedNode As New TreeNode
SelectedNode = TreeView1.SelectedNode
Messagebox.Show(SelectedNode.Text)
TreeView1.SelectedNode.Remove()
TreeView1.ExpandAll()
TreeView1.SelectedNode.ExpandAll()
TreeView1.SelectedNode.Collapse()
TreeView1.PathSeparator = "\"
MessageBox.Show(TreeView1.SelectedNode.FullPath)
TreeView1.CheckBoxes = True
TreeView1.ShowLines = False
TreeView1.FullRowSelect = True
TreeView1.LineColor = Color.Red
WebBrowser1.Url = New Uri("https://www.google.co.jp/")
If WebBrowser1.CanGoBack Then
End If
WebBrowser1.GoBack()
If WebBrowser1.CanGoForward Then
End If
WebBrowser1.GoForward()
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
End Sub
WebBrowser1.DocumentTitle
WebBrowser1.Stop()
WebBrowser1.Refresh()
WebBrowser1.Url.ToString()
WebBrowser1.Print()
WebBrowser1.ScriptErrorsSuppressed = True
※WebBrowserは、使える機能が限られているため、Webサイトの構成によりエラーが頻繁に表示されます。
そのエラーを表示させないためにはこちらの設定が必要です。