In my databound ComboBox, how do I set the SelectedItem property
Use the FindStringExact method. For example, if you have set the ComboBox’s ValueMember property to ‘OrderID’, then you could call comboBox1.SelectedIndex = comboBox1.FindStringExact(stringOrderID); where stringOrderID is the ‘orderID’ of the row to be selected.
What is the replacement for VB6’s SendKeys statement
It is the Send method from the SendKeys class found in the System.Windows.Forms namespace.
How do I make a class expandable within the property browser
Add a TypeConverter to your class type to tell the Property Browser it should be expandable. [TypeConverter(typeof(ExpandableObjectConverter))] public class MyClass { } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How do I add SubItems to a ListView control
Try code such as: ListViewItem item = new ListViewItem(‘NewItem’); item.SubItems.AddRange(new string[]{‘SubItem1’, ‘SubItem2’)}; listView1.Items.Add(item); listView1.Items.Add(new ListViewItem(new string[]{‘item1’, ‘item2’, ‘item3’, ‘item4’}); listView1.View = View.Details;
In my UITypeEditor for a collection, how do I change the ‘(collection)’ string to a string of my own
The string ‘(Collection)’ is coming from the TypeConverter on that property, which is CollectionConverter. To modify this value, do the following… [TypeConverter(typeof(MyCollectionConverter)] public class MyCollection : SomeBaseCollectoin { // … } internal class MyCollectoinConverter : System.ComponentModel.CollectionConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (value is ICollection) { return ‘You can return what ever string value you want here’; } } return base.ConvertTo(context, culture, value, destinationType); } } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)