Click here to Skip to main content
16,006,749 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralWindow Location, Multiple Monitor Pin
Matt Philmon20-Feb-04 19:46
Matt Philmon20-Feb-04 19:46 
GeneralRe: Window Location, Multiple Monitor Pin
apferreira26-Feb-04 7:47
apferreira26-Feb-04 7:47 
Questionhow to access web service with SSL from windows application (C#)? Pin
zhyluopro20-Feb-04 13:14
zhyluopro20-Feb-04 13:14 
GeneralTypecast a control Pin
john4620-Feb-04 5:27
john4620-Feb-04 5:27 
GeneralRe: Typecast a control Pin
Judah Gabriel Himango20-Feb-04 6:11
sponsorJudah Gabriel Himango20-Feb-04 6:11 
GeneralRe: Typecast a control Pin
Judah Gabriel Himango20-Feb-04 7:17
sponsorJudah Gabriel Himango20-Feb-04 7:17 
GeneralRe: Typecast a control Pin
john4620-Feb-04 9:29
john4620-Feb-04 9:29 
GeneralRe: Typecast a control Pin
Charlie Williams20-Feb-04 6:54
Charlie Williams20-Feb-04 6:54 
Both Listbox and ComboBox inherit from ListControl, so it would be somewhat logical to assume that's where the Items porperty comes from. If only it were that easy.

Although they share a common name, Items properties represent differents type of objects in Listbox and ComboBox (ListBox.ObjectCollection and ComboBox.ObjectCollection, respectively).

Therefore, there's no common ancestor you can cast to and call Items.Clear().

As for your question of how to create a generic solution, there is a way, although it may be overkill for what you're looking for.
using System.Reflection;
   
//Will throw a NullReferenceException if the Control doesn't have an Items property

object collection = ctrl.GetType().GetProperty("Items").GetValue(ctrl, null);
collection.GetType().GetMethod("Clear").Invoke(collection, null);
Alas, the 'generic' solution is usually not the easiest

Charlie

if(!curlies){ return; }
GeneralRe: Typecast a control Pin
Charlie Williams20-Feb-04 7:29
Charlie Williams20-Feb-04 7:29 
GeneralRe: Typecast a control Pin
john4622-Feb-04 6:16
john4622-Feb-04 6:16 
QuestionWhy is System.Web.Mail.SmtpMail.Send so slow? Pin
Anonymous19-Feb-04 8:37
Anonymous19-Feb-04 8:37 
AnswerRe: Why is System.Web.Mail.SmtpMail.Send so slow? Pin
Giles19-Feb-04 9:04
Giles19-Feb-04 9:04 
General.NET and DLL callbacks Pin
Michael Breier19-Feb-04 5:54
Michael Breier19-Feb-04 5:54 
GeneralRe: .NET and DLL callbacks Pin
Matt Philmon20-Feb-04 19:41
Matt Philmon20-Feb-04 19:41 
GeneralRe: .NET and DLL callbacks Pin
Michael Breier22-Feb-04 22:00
Michael Breier22-Feb-04 22:00 
GeneralRe: .NET and DLL callbacks Pin
Michael Breier22-Feb-04 22:17
Michael Breier22-Feb-04 22:17 
GeneralRe: .NET and DLL callbacks Pin
David Moody26-Feb-04 4:36
David Moody26-Feb-04 4:36 
GeneralRe: .NET and DLL callbacks Pin
Michael Breier10-Mar-04 6:46
Michael Breier10-Mar-04 6:46 
GeneralRe: .NET and DLL callbacks Pin
David Moody10-Mar-04 7:22
David Moody10-Mar-04 7:22 
GeneralSpeed of .NET Pin
Joel Holdsworth18-Feb-04 11:17
Joel Holdsworth18-Feb-04 11:17 
GeneralRe: Speed of .NET Pin
Ivor S. Sargoytchev18-Feb-04 16:06
Ivor S. Sargoytchev18-Feb-04 16:06 
GeneralRe: Speed of .NET Pin
Colin Angus Mackay19-Feb-04 1:04
Colin Angus Mackay19-Feb-04 1:04 
GeneralAutomation Pin
yyf18-Feb-04 5:45
yyf18-Feb-04 5:45 
GeneralRe: Automation Pin
John Kuhn18-Feb-04 21:44
John Kuhn18-Feb-04 21:44 
GeneralTo DOTNET or NOTDOTNET Pin
RichardGrimmer18-Feb-04 2:56
RichardGrimmer18-Feb-04 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.