static public class LISTVIEW
{
static public string Get_col_width(ListView lv)
{
int i, n;
string s = "";
ListView.ColumnHeaderCollection h = lv.Columns;
n = h.Count;
for (i = 0; i < n; i++)
{
s += h[i].Width + ",";
}
return s;
}
static public string Get_col_name(ListView lv)
{
int i, n;
string s = "";
ListView.ColumnHeaderCollection h = lv.Columns;
n = h.Count;
for (i = 0; i < n; i++)
{
s += h[i].Text + ";";
}
return s;
}
static public void Set_col_name(ListView lv, string col_name,//="sheet;cell;text;min;value;max"
string default_col_name)//="sheet;cell;text;min;value;max;"
{
int i, n;
string[] c = col_name.Split(';');
string[] d=null;
string name;
ListView.ColumnHeaderCollection h = lv.Columns;
h.Clear();
n = c.Length;
try
{
for (i = 0; i < n; i++)
{
//데이터가 부족한 경우, 기본설정값 사용
name = c[i];
if ((name == "") || (name == null))
{
if(d == null)
{
d = default_col_name.Split(';');
}
else
{ }
name = d[i];
}
else
{ }
h.Add(name);
}
}
catch
{ }
}
static public void Set_col_width(ListView lv, string col_width,//="50,50,200,100,50,50,50"
string default_col_width)
{
int i, n;
string[] c = col_width.Split(',');
string[] d=null;
string s;
ListView.ColumnHeaderCollection h = lv.Columns;
n = c.Length;
if(n>h.Count)
{
n = h.Count;
}
else
{ }
try
{
for (i = 0; i < n; i++)
{
//읽은 데이터가 부족할 경우, 기본 데이터 사용
s = c[i];
if ((s == "") || (s == null))
{
if (d == null)
{
d = default_col_width.Split(',');
}
else
{ }
s = d[i];
}
else
{ }
h[i].Width = Convert.ToInt32(s);
}
}
catch
{ }
}
static public void Ini_load_header_name_width(string Section, ListView lv,
string col_name,//="번호;제목;가격;기타;"
string col_width)//="50,50,200,100,"
{
IniFile ini = new IniFile();
ini.SetSection(Section);
string s;
s = ini.Gets("COL_NAME", col_name);
Set_col_name(lv, s, col_name);
s = ini.Gets("COL_WIDTH", col_width);
Set_col_width(lv, s, col_width);
}
static public void Ini_save_header_name_width(string Section, ListView lv)
{
IniFile ini = new IniFile();
ini.SetSection(Section);
ini.Puts("COL_NAME", Get_col_name(lv));
ini.Puts("COL_WIDTH", Get_col_width(lv));
}
}