kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
ciao sapete dirmi come potrei creare un browser a schede....
usando il controllo tabcontrol...XD
|
|
BugliL (Member)
Pro
Messaggi: 135
Iscritto: 09/08/2009
|
Postato originariamente da kejan:
ciao sapete dirmi come potrei creare un browser a schede....
usando il controllo tabcontrol...XD |
Il browser a schede come lo vuoi fare tu è composto da 2 parti:
1) Componente WebBrowser http://www.dreamincode.net/forums/showtopic45487.htm
2) TabControl
Basta mettere in una scheda il componente WebBrowser...
Per ogni volta che viene richiamata una nuova scheda instanzi la scheda di base del controllo... |
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
si ma come faccio ad aprire una nuova finestra con un tabcontrol come dici tu....
|
|
BugliL (Member)
Pro
Messaggi: 135
Iscritto: 09/08/2009
|
Postato originariamente da kejan:
si ma come faccio ad aprire una nuova finestra con un tabcontrol come dici tu.... |
Non una finestra... una nuova tab
Queta è una funzione molto utile....
Codice sorgente - presumibilmente VB.NET |
Public Function CloneControl(ByVal sourceControl As Control) As Control Dim result As Control = Nothing Try Dim t As Type = sourceControl.[GetType]() result = DirectCast(Activator.CreateInstance(t), Control) Dim sourceProps As PropertyDescriptorCollection = TypeDescriptor.GetProperties(sourceControl) Dim destProps As PropertyDescriptorCollection = TypeDescriptor.GetProperties(result) Dim i As Integer = 0 While i < sourceProps.Count If sourceProps(i).Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) Then Dim sourceValues As Object = sourceProps(i).GetValue(sourceControl) If (TypeOf sourceValues Is IList) = True Then For Each child As Object In (TryCast(sourceValues, IList)) Dim childCtrl As Control = CloneControl(TryCast(child, Control)) Dim destValues As IList = TryCast(destProps(i).GetValue(result), IList) System. Diagnostics. Debug. Assert(Not destValues Is Nothing) If Not destValues Is Nothing Then destValues.Add(childCtrl) End If Next End If Else destProps(sourceProps(i).Name).SetValue(result, sourceProps(i).GetValue(sourceControl)) End If System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While Return result Catch ex As Exception ' Your exception handling here… MsgBox(ex.ToString) End Try End Function
|
Tramite questa linea di codice...
Codice sorgente - presumibilmente C# / VB.NET |
Dim newTab As TabPage = CloneControl(NomeTab)
|
Ultima modifica effettuata da BugliL il 16/08/2009 alle 19:55 |
|
maxas (Normal User)
Rookie
Messaggi: 53
Iscritto: 26/07/2009
|
scusa ma ci sono alcune cose nel codice che da errore
questo e il codice
Codice sorgente - presumibilmente VB.NET |
Public Class Form1 Dim newTab As TabPage = CloneControl(NomeTab) Public Function CloneControl(ByVal sourceControl As Control) As Control Dim result As Control = Nothing Try Dim t As Type = sourceControl.[GetType]() result = DirectCast(Activator.CreateInstance(t), Control) Dim sourceProps As PropertyDescriptorCollection = TypeDescriptor.GetProperties(sourceControl) Dim destProps As PropertyDescriptorCollection = TypeDescriptor.GetProperties(result) Dim i As Integer = 0 While i < sourceProps.Count If sourceProps(i).Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) Then Dim sourceValues As Object = sourceProps(i).GetValue(sourceControl) If (TypeOf sourceValues Is IList) = True Then For Each child As Object In (TryCast(sourceValues, IList)) Dim childCtrl As Control = CloneControl(TryCast(child, Control)) Dim destValues As IList = TryCast(destProps(i).GetValue(result), IList) System. Diagnostics. Debug. Assert(Not destValues Is Nothing) If Not destValues Is Nothing Then destValues.Add(childCtrl) End If Next End If Else destProps(sourceProps(i).Name).SetValue(result, sourceProps(i).GetValue(sourceControl)) End If System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While Return result Catch ex As Exception ' Your exception handling here… MsgBox(ex.ToString) End Try End Function End Class
|
errore lo da in queste parti
Dim newTab As TabPage = CloneControl(NomeTab)
e NomeTab l'errore
e poi
Dim sourceProps As PropertyDescriptorCollection=TypeDescriptor.GetProperties(sourceControl)
Dim destProps As PropertyDescriptorCollection=TypeDescriptor.GetProperties(result) IfsourceProps(i).Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) Then
ti consiglio di cercare con internet...
Ultima modifica effettuata da maxas il 16/08/2009 alle 23:13 |
|
BugliL (Member)
Pro
Messaggi: 135
Iscritto: 09/08/2009
|
Postato originariamente da maxas:
scusa ma ci sono alcune cose nel codice che da errore
errore lo da in queste parti
Dim newTab As TabPage = CloneControl(NomeTab)
e NomeTab l'errore
e poi
Dim sourceProps As PropertyDescriptorCollection=TypeDescriptor.GetProperties(sourceControl)
Dim destProps As PropertyDescriptorCollection=TypeDescriptor.GetProperties(result) IfsourceProps(i).Attributes.Contains(DesignerSerializationVisibilityAttribute.Content) Then |
NomeTab è il nome della TabPage principale da copiare...
Pensavo fosse chiaro...
1) Se la TabPage da copiare si chiama "CIAO_Pippo" il codice è
Codice sorgente - presumibilmente C# / VB.NET |
Dim newTab As TabPage = CloneControl(CIAO_Pippo)
|
2) Non puoi richiamare una funzione che gestisce un controllo prima ancora che la form sia stata creata... inserisci
Codice sorgente - presumibilmente C# / VB.NET |
Dim newTab As TabPage = CloneControl(CIAO_Pippo)
|
in un evento...
Postato originariamente da maxas:ti consiglio di cercare con internet... |
In che senso? |
|
lorenzo (Normal User)
Guru
Messaggi: 1178
Iscritto: 15/04/2008
|
lasciando perdere per un momento i commenti su internet di maxas() penso che quella funzione sia davvero inutile per il problema del topic
lui deve creare a runtime, ogni volta che clicca su una tab, un oggetto WebBrowser, settando un paio di proprietà e basta....non vedo la necessità di clonare in quel modo(assurdo a parer mio) un controllo....
EDIT: se la tab non esiste la si crea anch'essa a runtime, ma nulla di più....perché complicarsi la vita in quel modo?
Ultima modifica effettuata da lorenzo il 17/08/2009 alle 11:30 |
|
kejan (Normal User)
Newbie
Messaggi: 20
Iscritto: 12/08/2009
|
Ho cercato su internet e sono riuscito a scrivere questo codice...
Codice sorgente - presumibilmente VB.NET |
Public Class Form1 Dim int As Integer = 0 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Browser As New WebBrowser TabControl1.TabPages.Add("New Page") Browser.Name = "Web Browser" Browser.Dock = DockStyle.Fill TabControl1.SelectedTab.Controls.Add(Browser) int = int + 1 CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("www.google.it") End Sub End Class
|
funziona il problema che qualsiasi pagina visito viene memorizzata nella cronologia di IE come posso fare che non avvenga...
|
|
lorenzo (Normal User)
Guru
Messaggi: 1178
Iscritto: 15/04/2008
|
il controllo WebBrowser funziona come funziona il tuo browser predefinito...
|
|