M
mp
changing a control size/location at runtime may be a bad idea
depending on other control sizes/locations
but in this case i want to size a column so i can read the entries
in this context is it a bad idea to try and get the size from the entries
themselves in some way?
is there a less amature(sp?) way to set column0.width to fit the longest
entry?
(lvCriteriaList is a listview)
(_criteriaList is a SortedDictionary<string,string>)
lvCriteriaList.Columns.Add("Criteria");
lvCriteriaList.Columns.Add("Code");
lvCriteriaList.View = View.Details;
lvCriteriaList.CheckBoxes = true;
foreach (KeyValuePair<string,string> kvp in _criteriaList)
{
int longestItem=0;
int magicNumber=18;<<<determined by trial/error during design-testing
with expected values in dict.
if (kvp.Value.Length > longestItem)
longestItem = kvp.Value.Length;
ListViewItem lvitem= lvCriteriaList.Items.Add(new
ListViewItem(kvp.Value));
lvitem.SubItems.Add(kvp.Key);
lvCriteriaList.Columns[0].Width = longestItem*magicNumber;//<<<bad i know
lvCriteriaList.Width = ???determine based on above somehow....
}
depending on other control sizes/locations
but in this case i want to size a column so i can read the entries
in this context is it a bad idea to try and get the size from the entries
themselves in some way?
is there a less amature(sp?) way to set column0.width to fit the longest
entry?
(lvCriteriaList is a listview)
(_criteriaList is a SortedDictionary<string,string>)
lvCriteriaList.Columns.Add("Criteria");
lvCriteriaList.Columns.Add("Code");
lvCriteriaList.View = View.Details;
lvCriteriaList.CheckBoxes = true;
foreach (KeyValuePair<string,string> kvp in _criteriaList)
{
int longestItem=0;
int magicNumber=18;<<<determined by trial/error during design-testing
with expected values in dict.
if (kvp.Value.Length > longestItem)
longestItem = kvp.Value.Length;
ListViewItem lvitem= lvCriteriaList.Items.Add(new
ListViewItem(kvp.Value));
lvitem.SubItems.Add(kvp.Key);
lvCriteriaList.Columns[0].Width = longestItem*magicNumber;//<<<bad i know
lvCriteriaList.Width = ???determine based on above somehow....
}