forked from sll552/DiscordBee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaceholderTableWindow.cs
37 lines (33 loc) · 1010 Bytes
/
PlaceholderTableWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MusicBeePlugin
{
public partial class PlaceholderTableWindow : Form
{
public PlaceholderTableWindow()
{
InitializeComponent();
}
public void UpdateTable(Dictionary<string, string> newData)
{
dataGridView1.DataSource = null;
dataGridView1.Columns.Clear();
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = newData.ToList().ToSortableBindingList();
dataGridView1.Refresh();
var lastcol =
dataGridView1.Columns.GetLastColumn(DataGridViewElementStates.Visible, DataGridViewElementStates.None);
if (lastcol != null)
{
lastcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
col.SortMode = DataGridViewColumnSortMode.Automatic;
}
}
}
}