How to add an extern reference to a Win32 API
We have two suggestions with sample projects how you host a WebBrowser control inside a form and display HTML contents and listen to events such as NavigateComplete or BeforeNavigate. Of course there are many other ways to do this. Download htmlviewer.zip for two sample projects for the suggestions discussed below. 1) The first suggestion is to generate an ActiveX wrapper for shdocvw using the aximp tool. The command line for this tool should be as follows: aximp c:\windows\system32\shdocvw.dll This will generate the following assemblies. Generated Assembly: D:\Syncfusion\faq\HtmlBrowser\HtmlViewer2\SHDocVw.dll Generated Assembly: D:\Syncfusion\faq\HtmlBrowser\HtmlViewer2\AxSHDocVw.dll Now you can reference these dlls in your project and use AxWebBrowser. In the attached HtmlViewer2 sample we have derived a HtmlControl class from AxWebBrowser and added some properties that let you specify a CSS Stylesheet and the Html content as a string. 2) Our second sample lets you bypass the generation of a ActiveX wrapper. You don’t have to include and ship shdocvw.dll and axshdocvw.dll. In the attached HtmlViewer sample, we derived from AxHost and attached our own IWebBrowserEvents interface by overriding the CreateSink, AttachInterfaces and DetachSink methods. You can use HtmlControl in your form and specify HTML content by assigning a HTML string to HtmlControl. A cascading style sheet can be specified by assigning a path name to the CascadingStyleSheet property. The sample demonstrates how to use a CSS style sheet that has been embedded as a resource in the assembly.
How do you prevent serialization of certain child controls in your Composite Control
One solution is to use a panel that has a picturebox placed on it with DockStyle.Fill. This will make the picturebox assume the size of the panel. In addition, set the DockPadding.All property to the width of the desired border. Then in the Panel’s OnPaint method, call the baseclass and then paint the desired borders. Here are both VB and C# projects that illustrate how you might go about this. The derived PicturePanel class has properties that allow you to set the bordersize and color as well as the image that is to be displayed. This sample retrieves the image from an embedded
How do I programmatically select a row in DataGrid?
To programmatically select a row, you need to call: [C#] //select row 1 this.dataGrid1.Select(1); [VB.NET] 'select row 1 Me.dataGrid1.Select(1)
Why do calling Focus() on a control not set focus on it?
Note that when you call this method the control should be visible, otherwise the focus will not be set. Hence calling this in say Form_Load on a control in the form will be ineffective. You should instead consider give that control an appropriate TabIndex, so that it will be the first focused control.
How can I programatically set the rowheight of a row in my DataGrid
One way you can do this is to use reflection to access the DataGrid internal row objects which are not publicly exposed. This solution was suggested by Matthew Benedict in a private communication. Here are both VB and C# sample projects showing how you might do this. The sample provides a class that you can instantiate by passing a DataGrid, creating a rowHeights object. Once you create this object, you can use an indexer on the object to set and get the rowheights.