views:

285

answers:

3

I have a VB.NET program where I'm using a WebBrowser control to simulate a timesheet form. For data entry, I'm using a DateTimePicker control that sits on top of the WebBrowser control, which I have programmed to move on top of the cell of the table in the WebBrowser control when the WebBrowser control is clicked on. (If you want to ask why I'm not using a DataGridView, it's for formatting purposes)

My problem is that there are parts of the WebBrowser (headers, the scrollbars) that I want to treat as being above the DateTimePicker, especially while the user is scrolling the WebBrowser. My idea is to somehow provide a rectangle to the DateTimePicker that will make it only draw the part of the control that's within that region. Unfortunately I'm almost brand new to .NET (but not programming in general) and after spending half the day googling I still have no idea how to do it.

Does anyone know how to do this and can show me/point me somewhere that shows me how?

A: 

If this is a brand new application, have you considered using WPF instead of a WebBrowser?

Sean
+2  A: 

I think you're looking for the Control.Invalidate method.

But after re-reading your question, I'm not really sure. Maybe you're trying to have the DateTimePicker get clipped by the borders of the WebBrowser control... In that case, you need to make sure that you add the DateTimePicker to the Controls collection of the WebBrowser.

I ran a simple test by creating a form with a WebBrowser, a DateTimePicker, and a Button. Place this code in the button's Click event:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    WebBrowser1.Controls.Add(DateTimePicker1)
End Sub

If you set things up so that the DTP extends over the edge of the WebBrowser, you'll see that it gets clipped once you click the button. The reason it moves is that it's positioned relative to it's container, which becomes the WebBrowser once you click the button.

JeffK
A: 

JeffK: I just tried adding the DTP to the WebBrowser's control collection but the DTP still displays overtop the WebBrowser's scrollbars and table headers (the table headers are fixed-positioned HTML elements). Do you have any ideas how to keep that from happening?

Sean: No, I have actually never heard of WPF before you mentioned it. Do you have any good links to where I can learn more about it/how to use it?

Ski
Here is an introduction to WPF on MSDN - http://msdn.microsoft.com/en-us/library/aa970268.aspx
Sean