|
A typed DataSet is a class that is derived from DataSet that is "pre-configured" with your database schema. Other typed classes deriving from DataTable and other supporting classes are also defined as well.
Typed DataSet s are very handy when using the designer in VS.NET for data-bound controls like the DataGrid because the designer can discover all your table and column names so you can bind to them easily. Simply open the toolbox, select the Data catagory, then drag a "DataSet" in. When it asks, choose to create a typed DataSet from the list (if it's defined in your project) or click "Referenced Projects..." to find typed DataSet s in projects that the current project references.
Why are they better? Well, first you don't have to define all your tables and columns programmatically; they're already defined in your new class. Second, they're much faster depending on how you access data. Commonly, people will use code like this:
string s = (string)dataSet1.Tables["MyTable"].Rows[0]["ID"]; That is a very expensive call. First, the tables must be enumerated to find the one named "MyTable" (which includes expensive, case-insensitive string searches). Then the first row is obtained and the column with the name "ID" is found in a simiar fashion, except that columns are first enumerated and then the N'th row's data is retrieved.
When you use a typed DataSet and use code like the following, the lookups are not necessary because the tables and references columns are references to the tables and columns already instantiated - no lookups are required:
string s = myDataSet1.MyTable.Rows[0].ID; Also notice I didn't have to cast to a string? While casting is done internally in the typed DataSet class, you don't have to worry about cast exceptions in your code, which is good encapsulation.
Finally, when you use the designer to generate a derivative DataAdapter , all the table and column mappings are done for you automatically.
While the benefits are great when using the VS.NET designers, the runtime benefits are good, too. Few to no lookups are required and it's easier to discover type information at runtime for abstract implementations.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi guys..
I've a project and I want to put my principal web page in cache, and the server should refresh the information each 5 or 10 minutes.
I wait for yours ideas !!!
Thanks..
.............................
|
|
|
|
|
Here's an idea: try google[^]. COUNTLESS projects have been written that already do this and the source for many - in about every language, framework, and platform you can think of - is available. This is a trivial thing to implement. In .NET, for instance, you could simply use an HttpWebRequest (preferrably using async operations) on a timer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi...
Really now I don't know who I can print only 1 or 2 or three decimal digits of a float number in C#. 1.234566 --result--> 1.23 (two decimals places)
How I can do that ??
Thanks...
.............................
|
|
|
|
|
ToString has overloaded methods that allow you to provide a format specifier.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
A great site for formatting numbers:
http://authors.aspalliance.com/aspxtreme/aspnet/types/numericformatstrings.aspx
|
|
|
|
|
Hi ppl!
In my program I need to catch the axWebBrowser1 'DocumentComplete' event. But I find out that this event happens more than 1 times !!!?? At some pages it even happens 7 or 8 times !! Why is this ??? And how I can tell if this is very last chance when it happens (document completly loaded) or there's will be more 'DocumentComplete' events ???
Please help - this is extremly important to me
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
Hi.
I believe that this link[^] adequately addresses your issue. (Unless you can't figure out how to do the pDisp comparison in C#.)
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi man !!
Thanks for the answer - very helpfull. But you see - I'm still having problems with determinate when exactly web page is loaded
I'm trying to receive IHTMLCollection from axWebBrowser.Document from some news web site (the url is http://www.lenta.ru) For the very bad luck I choosed this site to test my collection with and I still receive a weird result Sometimes the size of collection is 2069 elements and sometimes (I just hit refresh button I receive collection of 2065 (!) elements and so on... I don't know what to do Seems to me I can't really lock on the page and some elements are missing (?) sometimes ???
Any sugestions ???
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
I'm having trouble understanding what your code is really doing. Where did this collection with 2056 elements come from?
The axWebBrowser.Document itself shouldn't be changing, but its content will be.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Here you go the full (almost) source code
<br />
this.webBrowser.AddressBar = false;<br />
this.webBrowser.Dock = DockStyle.Fill;<br />
this.webBrowser.FullScreen = true;<br />
this.webBrowser.MenuBar = false;<br />
this.webBrowser.Offline = false;<br />
this.webBrowser.RegisterAsBrowser = true;<br />
this.webBrowser.RegisterAsDropTarget = false;<br />
this.webBrowser.Silent = true;<br />
this.webBrowser.StatusBar = false;<br />
this.webBrowser.TheaterMode = true;<br />
.<br />
.<br />
.<br />
<br />
<br />
<br />
private void webBrowser_DocumentComplete (object sender,AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)<br />
{<br />
++this.tempCounter;<br />
<br />
if ( sender.Equals((object)this.webBrowser) && this.webBrowser.ReadyState.Equals(SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE))<br />
{<br />
MessageBox.Show ("Done loading\n\nLoaded " + this.tempCounter.ToString() +" times", "Document loaded");<br />
<br />
htmlDocGlobal = (mshtml.IHTMLDocument2) webBrowser.Document;<br />
<br />
if (clickEvent == null)<br />
{<br />
clickEvent = (mshtml.HTMLDocumentEvents2_Event) htmlDocGlobal;<br />
clickEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler (On_MouseClick);<br />
}<br />
}<br />
}<br />
<br />
<br />
private bool On_MouseClick (mshtml.IHTMLEventObj e)<br />
{<br />
if (e.button.Equals (0))<br />
{<br />
<br />
ArrayList m_PathToElement = new ArrayList();<br />
IHTMLElement m_Parent = null;<br />
IHTMLElement m_Child = null;<br />
IHTMLElementCollection m_ParentCol = null;<br />
IEnumerator colEnum = null;<br />
<br />
m_Child = e.srcElement;<br />
m_Parent = m_Child.parentElement;<br />
<br />
while (m_Child.parentElement != null)
{ {<br />
m_ParentCol = (IHTMLElementCollection) m_Parent.all;<br />
<br />
System.Windows.Forms.Application.DoEvents ();
colEnum = m_ParentCol.GetEnumerator ();<br />
colEnum.MoveNext ();
.<br />
.<br />
.<br />
.<br />
.<br />
Then I go throught collection and search for ckicked element till the root element.<br />
}<br />
}<br />
}<br />
I make some checks for received htmlDocGlobal and the size is different all the time
If you need the full source code please contact me by eMail
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
It looks like you have 2 separate problems. First, test only the part that determines whether the page has finished loading. Once that is ready, then work on those other portions. The simpler you make each test, the easier it is to determine where the problem lies.
If you need the complete page and all of its elements to finish loading before you do anything, then you'll need to track each sub-document and note when that has finished as well. Then, when they are all completely loaded, you can do your work.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Yeah I thought about - checking all elements in the page for .ReadyState but I don't know how to do it Can you show me some code ???
(I check my prog on www.lenta.ru and this web page have 6 frames and 1 pop-up window)
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
One way to do that would be to add each new document element to a collection when the document state changes. (If your ArrayList doesn't Contain() the document element, then Add() it.) Later, when the state of all those documents is complete, then test to see if you have the information you should have.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Heres the deal:
I was looking at a control this guy made, its a menu control but behaves in a way I have never seen.
- You place his menuProvider control on a form (in design mode).
- You place the standard .NET mainMenu control on the form as well.
Now, You can add menuEntries to the .NET mainMenu control -- but in the properties panel it has a new property that ties it to the menuProvider. This standard non-subclassed .NET mainMenu has a new custom property?
How?
Did I miss a huge chunk about programming windows controls where you can modify properties of standard delivered objects?
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
It sounds like he used the IExtenderProvider interface, which is implemented by the ToolTip and HelpProvider controls that you may have used already. Take a look at the docs here[^].
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
As the first reply said, he is using an IExtenderProvider . This is a common approach to providing functionality without having to redefine the types you want to extend. The HelpProvider is one example, as is the ToolTip and ErrorProvider components.
There's several good articles here on CodeProject about them, too. Try the following search[^]. There's a lot of good tips / ideas in these implementations as well.
I've also seen these things used for menus to provide images. While many people extend MenuItem and owner-draw the icons, some have used an IExtenderProvider so that you don't have to break the designer trying to use derivative (or completely custom) classes. I created one some time back to provide column sorting for a ListView on any column without going to the usual trouble of providing your own IComparer implementation and overriding key functinality. The provider does it for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am currently writing a DockingManager which can be implemented by a form and controls Control dervied clases which also implement my IDockingControlled interface.
The user can drag the control to the desired side of the form which they want the control to dock to or they can drag it away from the sides to have it floating. All this works.
However when the control docks to the side of the form, if the form is larger than the control then the control is resized and the controls original size is drawn fine, however the extra area form the resize flashes as if the control is being constantly redrawn and undrawn in the area.
Does anyone have any idea what the problem could be?
thanks
|
|
|
|
|
So when you dock a control, the control is resized or it's not? You said "the control is resized and the controls original size is drawn", but also mentioned in several places that's it's resized. Is it resized or isn't it?
If it's being resized, first make sure that your painting operations (if any) don't invalidate the entire region and only invalidate the regions that need re-drawing. Another thing to look into is double-buffering the painting of these controls if you're writing them yourself. See the Control.SetStyle method and ControlStyles enumeration documentation for more information on this.
Also, if you can, make use of a Control 's Dock property, which makes resizing a control dynamically a little smoother. You can resize it yourself but make sure you do it quickly without a lot of calculations. This most likely isn't the problem, but it's something to keep in mind.
If this doesn't help you, some code snippets might be helpful to see what's going on. With what you provided, it's a little difficult to determine exactly what's wrong.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Just a guess, but it sounds like you could have an infinite loop going on in the size changing event handler code. Put breakpoints on your SizeChanged and/or Resized handlers to see if they are repeatedly being called.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
it is. I think that when you set the Dock property in a control it constantly tries to resize the control to be the width of the container.
|
|
|
|
|
We have a very large multi-threaded Visual C++ product and are trying to migrate it, in manageable pieces, to C#. In many of these pieces a new C# form can be written to replace a similar C++ dialog. However, to ensure that the C# form gets overlapped properly, does not get hidden behind its parent etc. we the new C# win form dialog to be parented from whatever C++ window it was created. I haven't seen a way to accomplish this so I am hoping someone here might offer some advice or point me to an information source. Thanks in advance.
|
|
|
|
|
If you know the class name of the window, you can use FindWindow to find the handle of the window in question, assuming you can interop that function in C#. Then pass that handle as the parent of the window you create.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thanks Christian.
I actually know the window handle of the parent.
The problem ( I think ) is how do I convert a C++ window handle into something that I stuff into a C# form's parent property? Or is there a better way to solve this problem?
|
|
|
|
|
See my post[^] below. One way would be something like this (should only work in-proc, though):
Form f = (Form)Form.FromHandle(hWndParent); ...where hWndParent is an IntPtr that wraps the native HWND .
Microsoft MVP, Visual C#
My Articles
|
|
|
|