Windows Develop Bookmark and Share   
 index > Windows Forms General > problem implementing System.Windows.Forms.WebBrowser.Document control
 

problem implementing System.Windows.Forms.WebBrowser.Document control

Hi All,

I have problem implementing System.Windows.Forms.WebBrowser control. I am using this to build my HTML Editor in c#.net. But i dont know how to reduce the gap between lines... ? by default after pressing an enter key it assumes something like this <p>some text</p>. It introduce line gap after every enter.

How to resolve this..? And i have changed this <p> to <div> manually. this time it works fine.. how to do this programmatically..? and any way to introduce the tab keyhandler in code..?

How to resolve this

Raam_kimi  Thursday, February 07, 2008 10:49 AM

You can handle theWebBroswer.PreviewKeyDown event todetect the Enter key,replace it with the Shift+Enter key, see my sample at this thread for the details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2192207&SiteID=1

Zhi-Xin Ye  Monday, February 11, 2008 3:05 PM

Hi!

Changing <p> to <div> is not a good practice... First of all you can provide the document's CSSevery time the new document is created. The second solution is to handle the Enter key and write you own html code using current selection.

To be honest, I'd prefer the CSS solution.

Dmitry Kapezo  Thursday, February 07, 2008 3:57 PM

Shift-Enter should give you the <BR />

Enter should give you the <P>

JRQ  Thursday, February 07, 2008 4:03 PM

Thanks Dimitry,

i have tried that too.. adding line spacing in CSS... but samething happens again..

Thanks JRQ...

your idea works.. But i dont want <p> anywaywhile pressing enter.. i just need <br> for every enter... how do i switch this..

Raam_kimi  Friday, February 08, 2008 7:28 AM
I suggested the idea because Macromedia, FrontPage, andVisual Studio uses the same keys.I thinkit is a standard.

JRQ  Friday, February 08, 2008 5:25 PM

You can handle theWebBroswer.PreviewKeyDown event todetect the Enter key,replace it with the Shift+Enter key, see my sample at this thread for the details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2192207&SiteID=1

Zhi-Xin Ye  Monday, February 11, 2008 3:05 PM

Thanks Zhi-Xin,

this is what am exactly lookin for... It works fine now.

Raam_kimi  Tuesday, February 12, 2008 9:23 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGrid "New Row" Position
• InitializeComponent method
• Form that carries loads of data - looking for the best practice?
• Supressing Print Dialog in MSHTML
• Printing a web page
• customize the common file dialog of an existing program
• Setting SelectedItem on data-bound ComboBox
• problem with visual studio ,NET deployment!
• How to find date when the file is copy or created in the folder.
• How to Open Another application form as MDI client.