Click here to Skip to main content
15,904,156 members
Home / Discussions / C#
   

C#

 
AnswerRe: events between two threads Pin
PIEBALDconsult5-Dec-10 13:48
mvePIEBALDconsult5-Dec-10 13:48 
Questionhow make textbox or masked textbox take month and year only such as "mm/yyyy" Pin
Nabawoka5-Dec-10 5:43
Nabawoka5-Dec-10 5:43 
AnswerRe: how make textbox or masked textbox take month and year only such as "mm/yyyy" Pin
OriginalGriff5-Dec-10 6:11
mveOriginalGriff5-Dec-10 6:11 
AnswerRe: how make textbox or masked textbox take month and year only such as "mm/yyyy" Pin
Manfred Rudolf Bihy5-Dec-10 6:14
professionalManfred Rudolf Bihy5-Dec-10 6:14 
AnswerRe: how make textbox or masked textbox take month and year only such as "mm/yyyy" Pin
Nabawoka5-Dec-10 11:06
Nabawoka5-Dec-10 11:06 
AnswerRe: how make textbox or masked textbox take month and year only such as "mm/yyyy" Pin
Eddy Vluggen5-Dec-10 12:01
professionalEddy Vluggen5-Dec-10 12:01 
QuestionWeb Browser Tab Control problem Pin
nawoc5-Dec-10 5:06
nawoc5-Dec-10 5:06 
AnswerRe: Web Browser Tab Control problem Pin
Luc Pattyn5-Dec-10 7:46
sitebuilderLuc Pattyn5-Dec-10 7:46 
Hi,

here are some thoughts:

1.
seems you have a TabControl with one TabPage+WebBrowser added in Visual Designer; and inside newTabToolStripMenuItem_Click() you have code to add a TabPage+WebBrowser at run-time. This makes your first TabPage technically different from the future tab pages, not a very good idea:

Right now the first tab page has its WebBrowser kept in a variable webBrowser1 which is a class member of your Form; it is therefore the one that gets used in toolStripTextBox1_KeyPress(), no matter which TabPage is currently visible. The extra tab pages have a local variable, also called webBrowser1, but that only exists in the scope of newTabToolStripMenuItem_Click().

2.
almost all web browsers (e.g. FireFox) support tabs, and show a single TextBox for entering a URL; however the content depends on which TabPage is current. There basically are two ways to achieve this:
(a) really have a single TextBox and switch its content whenever the tab pages get switched;
(b) have a TextBox for each TabPage, all at the same Location, however all but one invisible. This might be easier.

3.
This is what I would do (assuming a Form called MyBrowser):
- with Visual Designer add a TabControl without Tab Pages to MyBrowser; and an invisible TextBox for URLs ("tbDummyURL").
- create a "BrowserPage" class that holds everything about a single tab page, including a TextBox "tbURL" and a WebBrowser "browser";
- create a variable MyBrowser.currentBrowserPage that holds the current browser page (initially null);
- create a method BrowserPage MyBrowser.AddTab; it would instantiate and return a BrowserPage, add its TabPage to the TabControl, set its TabPage.Tag to itself, and set its TextBox.Location to tbDummyURL.Location without making it visible.
- create a method MyBrowser.ShowTab(browserPage); it would set currentBrowserPage.tbURL.Visible false (unless null) and browserPage.tbURL.Visible true.

Then at run-time probably immediately create and show the first tab; whenever some button gets clicked create and show an additional tab; etc.

refinement: if you have another button to close the current tab, you need to remove the TabPage, and show again the previous tab. The proper way would use a most-recently-used approach, which you can implement with a List<BrowserPage> in MyBrowser. Then ShowTab(browserPage) should remove browserPage from the list, and add it again, effectlively moving it (if it was already in the list) to the last position in the list. So, closing a tab would remove it from the list, and the now last entry, if any, should be shown.

This may be a bit much, I suggest you try it step by step. Ask again if you get stuck (but please use PRE tags, not CODE tags, for code snippets).

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.


GeneralRe: Web Browser Tab Control problem Pin
nawoc5-Dec-10 9:42
nawoc5-Dec-10 9:42 
GeneralRe: Web Browser Tab Control problem Pin
Luc Pattyn5-Dec-10 9:44
sitebuilderLuc Pattyn5-Dec-10 9:44 
QuestionShould I be using inhertance for this? Pin
Jacob D Dixon4-Dec-10 15:26
Jacob D Dixon4-Dec-10 15:26 
AnswerRe: Should I be using inhertance for this? Pin
PIEBALDconsult4-Dec-10 16:30
mvePIEBALDconsult4-Dec-10 16:30 
GeneralRe: Should I be using inhertance for this? [modified] Pin
Jacob D Dixon4-Dec-10 17:14
Jacob D Dixon4-Dec-10 17:14 
GeneralRe: Should I be using inhertance for this? Pin
PIEBALDconsult5-Dec-10 3:49
mvePIEBALDconsult5-Dec-10 3:49 
GeneralRe: Should I be using inhertance for this? Pin
Jacob D Dixon5-Dec-10 4:15
Jacob D Dixon5-Dec-10 4:15 
GeneralRe: Should I be using inhertance for this? Pin
PIEBALDconsult5-Dec-10 8:53
mvePIEBALDconsult5-Dec-10 8:53 
GeneralRe: Should I be using inhertance for this? Pin
Jacob D Dixon6-Dec-10 16:17
Jacob D Dixon6-Dec-10 16:17 
GeneralRe: Should I be using inhertance for this? Pin
Spectre_0016-Dec-10 2:33
Spectre_0016-Dec-10 2:33 
AnswerRe: Should I be using inhertance for this? Pin
nortee5-Dec-10 21:29
nortee5-Dec-10 21:29 
AnswerRe: Should I be using inhertance for this? Pin
Steve Naidamast6-Dec-10 3:04
professionalSteve Naidamast6-Dec-10 3:04 
AnswerRe: Should I be using inhertance for this? Pin
mbb016-Dec-10 22:05
mbb016-Dec-10 22:05 
GeneralRe: Should I be using inhertance for this? Pin
nortee6-Dec-10 23:21
nortee6-Dec-10 23:21 
GeneralRe: Should I be using inhertance for this? Pin
Jacob D Dixon8-Dec-10 3:46
Jacob D Dixon8-Dec-10 3:46 
AnswerRe: Should I be using inhertance for this? Pin
James Lonero8-Dec-10 8:41
James Lonero8-Dec-10 8:41 
QuestionMessage Removed Pin
4-Dec-10 13:27
SRJ924-Dec-10 13:27 

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.