Skip to content

Instantly share code, notes, and snippets.

@KOZ60
KOZ60 / FitHeaderCell.md
Last active May 24, 2024 00:17
DataGridViewColumnHeaderCell

DataGridView のヘッダ列が他の行と文字の位置が違うので、DataGridViewTextBoxCell を参考にカスタマイズしました。

Public Class FitHeaderCell
	Inherits DataGridViewColumnHeaderCell

	Private Const DATAGRIDVIEWTEXTBOXCELL_ignoreNextMouseClick As Byte = 1
	Private Const DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetLeft As Byte = 3
	Private Const DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetRight As Byte = 4
	Private Const DATAGRIDVIEWTEXTBOXCELL_horizontalTextMarginLeft As Byte = 0
@KOZ60
KOZ60 / WaitableTimer.cs
Last active June 4, 2024 10:57
WaitableTimer
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32.SafeHandles;
[DesignerCategory("code")]
public class WaitableTimer : Component
{
private static object eventElapsed = new object();
@KOZ60
KOZ60 / NativeWindowBase.cs
Last active June 9, 2024 10:32
NativeWindowBase
using System;
using System.Windows.Forms;
public class NativeWindowBase : NativeWindow, IDisposable
{
private bool isDisposed;
private readonly Control owner;
public NativeWindowBase(Control owner) {
this.owner = owner;
@KOZ60
KOZ60 / PdbRead.cs
Created June 9, 2024 13:07
pdb ファイルからソースコードの位置を読み出す。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Mono.Cecil;
using Mono.Cecil.Pdb;
class Program
{
@KOZ60
KOZ60 / ShowPlayingFiles.cs
Last active June 9, 2024 14:01
現在演奏中のメディアファイルを列挙する
#nullable disable
#pragma warning disable
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using NAudio.CoreAudioApi;
@KOZ60
KOZ60 / DataGridView.md
Last active November 7, 2024 23:17
Five things should do when using DataGridView
  1. Enable double buffering
  2. Commit a value when selected in ComboBox/CheckBox
  3. Preventing and canceling drawing with BeginUpdate/EndUpdate
  4. When the ReadOnly property is changed to false, all columns from becoming editable
  5. Clipboard Operations (Clear/Paste)
using System;
using System.Text;
using System.Collections.Generic;
@KOZ60
KOZ60 / WideFileName.cs
Last active June 10, 2024 14:47
WideFileName.cs
using System;
using System.Runtime.InteropServices;
using static System.IO.Path;
/// <summary>
/// 32000 character filename
/// </summary>
/// <remarks>
/// When used as an argument to a Windows API, it will convert the filename to one that is 32K characters long.
/// You can also use the Win32FileName property as an argument to System.IO to support up to 32,000 characters.
@KOZ60
KOZ60 / XLColumn.cs
Last active June 13, 2024 14:26
XLColumn
using System;
using System.Text;
public class XLColumn : IEquatable<XLColumn>
{
private const string mask = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private readonly int columnIndex;
public XLColumn(int value) {
columnIndex = value;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
[DesignerCategory("code")]
public class FontDialogEx : FontDialog
@KOZ60
KOZ60 / AddCustomPaperSize.vb
Last active November 9, 2024 01:46
How to add custom paper to windows system
Imports System.Runtime.InteropServices
Module Module1
Sub Main()
AddCustomPaperSize(Nothing, "Custom Paper Sample", FormFlags.Printer, 10000, 10000, 9000, 9000)
End Sub
Public Enum FormFlags
User