ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
3074
3074
EMPFEHLEN
-
Hallo zusammen
Ich habe zwei Frage zu PropertyGrid:
1.) Wie kann ich ein Feld erstellen, mit einem OpenFileDialo. Bei den Einstellungen sollte man den Pfad zu einem File auswählen können.
2.) Wie kann ich bei einem anderen Feld die verfügbaren COM-Ports zur Auswahl auflisten?
Wie ich die Sammlung einfügen kann, weiss ich. Nur habe ich noch nicht herausgefunden, wie ich eine unbestimmte Sammlung (variable Sammlung) einfügen kann.
Code :1
public enum PortNames { COM1, COM2 };
Nun sollte aber in der Sammlung alle Verfügbaren COM-Ports stehen...
Gruss
-
Habe es selbst rausgefunden:
1.)Code :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
internal class FilteredFileNameEditor : UITypeEditor { private OpenFileDialog ofd = new OpenFileDialog(); public override UITypeEditorEditStyle GetEditStyle( ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; } public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { //ofd.FileName = value.ToString(); ofd.Filter = "XML-Datei (*.xml)|*.xml"; ofd.Title = "Datei auswählen"; if (ofd.ShowDialog() == DialogResult.OK) { return ofd.FileName; } return base.EditValue(context, provider, value); } } [Editor(typeof(FilteredFileNameEditor), typeof(System.Drawing.Design.UITypeEditor))] public string Pfad { get { return _path; } set { _path = value; } }
2.)Code :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 38 39 40 41
public class ComPortConverter : TypeConverter { public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { List<string> list = (context.Instance as AppSettings).PortList; StandardValuesCollection cols = new StandardValuesCollection(list); return cols; } } [CategoryAttribute("SerialPort") TypeConverter(typeof(ComPortConverter))] public string Port { get { return myStr; } set { myStr = value; } } List<string> list; [Browsable(false)] public List<string> PortList { get { if (list == null) { list = new List<string>(); string[] strSystemNames = System.IO.Ports.SerialPort.GetPortNames(); foreach (string strTemp in strSystemNames) { list.Add(strTemp); } } return list; } }
Falls es jemand anderst interessiert
Ähnliche Themen
-
PropertyGrid -> Properties von der abgeleiteten Klasse anzeigen
Von zarrandreas im Forum .NET CaféAntworten: 0Letzter Beitrag: 13.08.06, 12:48 -
PropertyGrid mehrzeilige Textbox
Von liquidbeats im Forum .NET Windows FormsAntworten: 4Letzter Beitrag: 05.04.06, 14:13 -
PropertyGrid: Eigene Enumeration im Grid auswählbar machen
Von Spock im Forum .NET ArchivAntworten: 5Letzter Beitrag: 18.11.05, 16:00 -
PropertyGrid?
Von jccTeq im Forum .NET ArchivAntworten: 2Letzter Beitrag: 02.02.04, 12:13





Zitieren
Login





