Click here to Skip to main content
16,004,977 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Reference to a non-shared member requires an object reference Pin
Geoff_300126-Jan-07 21:52
Geoff_300126-Jan-07 21:52 
QuestionHow to chage the backcolor of Listview control Pin
Exelioindia26-Jan-07 20:42
Exelioindia26-Jan-07 20:42 
QuestionGet name of dynamic created controls. Pin
.NetRams26-Jan-07 20:23
.NetRams26-Jan-07 20:23 
Questionimage manipulation Pin
sameersk26-Jan-07 18:16
sameersk26-Jan-07 18:16 
AnswerRe: image manipulation Pin
Christian Graus26-Jan-07 21:12
protectorChristian Graus26-Jan-07 21:12 
QuestionHelp with a Generic function Pin
TwoFaced26-Jan-07 13:16
TwoFaced26-Jan-07 13:16 
AnswerRe: Help with a Generic function Pin
Christian Graus26-Jan-07 13:25
protectorChristian Graus26-Jan-07 13:25 
GeneralRe: Help with a Generic function [modified] Pin
TwoFaced26-Jan-07 14:46
TwoFaced26-Jan-07 14:46 
I tried converting the code with a converter I found online but the result didn't seem to be correct. However, I think I understand what you mean, but that's not the problem. Simply put I need to convert a control to it's real type. If I could figure that out I'd be all set. Any thoughts on that? At the moment I have figured out solution. I realized I can convert the control to an object and then add it to the list. As long as Option Strict isn't on this works just fine because it just uses implicit conversion. I'm okay with that for now but I'd still like to know if there is anyway to convert a generic control to it's actual type without knowing it's type a head of time. Here is the code I'm using right now, which is working just fine.
'Returns a control array full of controls that match the desired type
Shared Function ControlArray(Of T as control)(ByVal container As Control) As T()
    'Controls to pass back
    Dim list As New List(Of T)

    For Each ctrl As Control In container.Controls
        'If child control is of the desired type T then add to list
        If ctrl.GetType Is GetType(T) Then list.Add(CType(ctrl, Object))
    Next
    'Return array
    Return list.ToArray
End Function


-- modified at 20:53 Friday 26th January, 2007
Okay, I take it back what I said about the constraint not being a problem. Well, technically it wasn't a problem but now that I have added a constraint I am now able to add a control type to my list which is of T. Now I don't need to convert to an object first, however, an implicit conversion is still needed so Option Strict can't be turned on. Thanks for your help! It worked perfectly. If you have any ideas on making this option strict friendly please let me know.
GeneralRe: Help with a Generic function Pin
Christian Graus26-Jan-07 21:15
protectorChristian Graus26-Jan-07 21:15 
GeneralRe: Help with a Generic function Pin
TwoFaced26-Jan-07 21:50
TwoFaced26-Jan-07 21:50 
GeneralRe: Help with a Generic function Pin
Christian Graus26-Jan-07 22:36
protectorChristian Graus26-Jan-07 22:36 
QuestionReportViewer "Report processing has been cancelled" [modified] Pin
Kschuler26-Jan-07 9:01
Kschuler26-Jan-07 9:01 
AnswerRe: ReportViewer "Report processing has been cancelled" Pin
Kschuler19-Feb-07 5:29
Kschuler19-Feb-07 5:29 
QuestionHow to override DataGridView Pin
GWbasicProgrammer26-Jan-07 8:17
GWbasicProgrammer26-Jan-07 8:17 
AnswerRe: How to override DataGridView Pin
Christian Graus26-Jan-07 10:08
protectorChristian Graus26-Jan-07 10:08 
GeneralRe: How to override DataGridView Pin
GWbasicProgrammer29-Jan-07 7:18
GWbasicProgrammer29-Jan-07 7:18 
Questioneditable listview control header Pin
pnpfriend26-Jan-07 6:17
pnpfriend26-Jan-07 6:17 
Questionloading text from a file... Pin
Sergi2526-Jan-07 4:14
Sergi2526-Jan-07 4:14 
AnswerRe: loading text from a file... Pin
Christian Graus26-Jan-07 10:07
protectorChristian Graus26-Jan-07 10:07 
AnswerRe: loading text from a file... Pin
gladsmhe26-Jan-07 11:04
gladsmhe26-Jan-07 11:04 
AnswerRe: loading text from a file... Pin
Geoff_300127-Jan-07 1:10
Geoff_300127-Jan-07 1:10 
GeneralRe: loading text from a file... Pin
Sergi2528-Jan-07 12:09
Sergi2528-Jan-07 12:09 
QuestionDisplay an Image Pin
Central_IT26-Jan-07 4:07
Central_IT26-Jan-07 4:07 
AnswerRe: Display an Image Pin
Christian Graus26-Jan-07 10:06
protectorChristian Graus26-Jan-07 10:06 
GeneralRe: Display an Image Pin
Central_IT29-Jan-07 22:51
Central_IT29-Jan-07 22:51 

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.