回答編集履歴
1
追記
test
CHANGED
@@ -3,3 +3,63 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
[ComboBoxの項目を自分で描画する - .NET Tips (VB.NET,C#...)](https://dobon.net/vb/dotnet/control/cbownerdraw.html)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# 追記
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
ComboBox をフォームに貼り付けて comboBox1 とし、Mode を OwnerDrawFixed に変更。DrawItem イベントを作成して次のように実装して実行したところ、頭合わせできました。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```C#
|
18
|
+
|
19
|
+
using System.Drawing;
|
20
|
+
|
21
|
+
using System.Windows.Forms;
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
namespace WindowsFormsApp1
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
public partial class Form1 : Form
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
public Form1()
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
InitializeComponent();
|
38
|
+
|
39
|
+
comboBox1.Items.AddRange(new[] { "abcdef\tghi", "Hello\tWorld" });
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
private void ComboBox1_DrawItem(object sender, DrawItemEventArgs e)
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
e.Graphics.DrawString(
|
50
|
+
|
51
|
+
comboBox1.Items[e.Index]?.ToString(),
|
52
|
+
|
53
|
+
comboBox1.Font,
|
54
|
+
|
55
|
+
new SolidBrush(comboBox1.ForeColor),
|
56
|
+
|
57
|
+
e.Bounds.Location);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
```
|