|
I have put a few of these together, and determining the percentages and getting the bar to move properly is not the easiest if you do it yourself.
For example: if you have a task you want to show this progress bar for and you created a record, notified one server of the new record, notified the database queue of the record, then created a summary page of the data, then you would have four tasks. However you can only set the value to 0, 25, 50, 75, 100 for those four values.
If, however, you take a look at here :
Pretty Good Splash Screen[^]
it contains the code to do a smooth progress bar. You can take the snippet of code from here and it manages the real time for each task. The first iteration it displays a blank page. All remaining iterations it displays a smooth progress bar.
Enjoy
______________________________
The Tao gave birth to machine language.
Machine language gave birth to the assembler.
The assembler gave birth to ten thousand languages.
Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
Beauty exists because we give a name to C#.
Bad exists because we give a name to COBOL.
|
|
|
|
|
Hello:
Is there any web site where I can find a very good explanation about the use of properties and mainly the justification of this in Database fields or (web)Forms fields ?
Many thanks!!!
|
|
|
|
|
You mean class properties? I don't see how this relates to databases or web form fields. If you are talking about creating business objects that map logical business data models (not a one-for-one mapping to a database, which is a poor design), then it's because it abstracts the actual data model away, leaving your code with an abstract way of declaring and using the relationships between your business objects. You can then implement a data tier which uses this information and updates the database. With an abstract design, you could always use a different data tier implementation to talk with different databases or even different data sources (like XML files).
If you mean class properties, this comes down to common object-oriented programming. The ubiquitous example is the Person and Company classes. Properties of these classes define the name of a person or company and other data associated with an instance of the class. You define methods when you actually want to perform an operation on that class.
If you're new to object-oriented development, I suggest you pick up a good book from www.amazon.com[^], or try a google search on object-oriented development[^]. The concept of properties and methods is common to all true object-oriented languages, like all the ".NET Languages" (those targeting the common language runtime, or CLR) and Java.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It is difficult to tell exactly what you are asking here - but if you talking about directly mapping database fields to a text box (or similiar control) on a form (of course, as the other message said, this is not a recommended OO methodology) but I'll use it sometimes for test purposes etc. If you are using Sql server you can use the following query to simply query the field metadata from Sql's System Tables. You can then loop through this recordset and assign the fields to the corresponding Form controls. If you are consistent with your naming conventions (i.e., naming the controls the same name as the fields) you can do this in one simple loop. In addition, you can setup your Update procedure and Insert procedure parameters in the same loop. As mentioned before, I wouldn't do this for a production App - but works great to model try some test cases or work up a quick "demo" etc...
Here is query to extract field meta data, this will work for a Table or a View since Sql stores the Columns Definitions for both in the same system tables. If you are using a Sproc for your select, the query is a little more complext but I can send that to you as well if you need it. Hope that helps...
ALTER PROCEDURE dbo.GetFields
(
@TableName varchar(128)
)
AS
SELECT
o.sysObjectID,
o.sysTableName,
c.name AS sysFieldName,
c.xtype AS sysDataTypeID,
t.name AS sysDataType,
c.length AS sysFieldSize,
c.colid AS sysOrdinalPosition,
c.isoutparam AS sysIsOutputParameter,
ISNULL(c.scale, 0) AS sysScale,
c.prec AS sysPrecision
FROM
dbo.systables o
INNER JOIN
dbo.syscolumns c
ON
o.sysObjectID = c.id
INNER JOIN
dbo.systypes t
ON
c.xtype = t.xtype
WHERE
o.sysTableName = @TableName
ORDER BY
c.colid
|
|
|
|
|
To add to this (for the original poster), a more common data-binding example is to bind against a DataSet , or a business object like I mentioned. Either one could be filled from a data source using the provider pattern so that the implementation is really independent from the data. This is a good OO design.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
After I add a row to a dataset how can I update that same row in the dataset after it has been added?
Thanks,
JJ
|
|
|
|
|
I was thinking the LoadDataRow method but this querys the Primary key for row which doesn't exist yet since generated by the database when records from dataset gets inserted. Or maybe I can't use an autoincrement field in the database table anymore because I have to supply one for new row inserts into dataset? Any Ideas?
Thanks,
JJ
|
|
|
|
|
If you set up your DataSet correctly with auto-increment columns and DataRelation s between then, the SqlDataAdapter should take this into account automatically, which is one reason that most InsertCommand properties use a SqlCommand comprised of an INSERT followed by a SELECT (separated by a semi-colon). Another reason is sometimes there may be other auto-generated fields that are optional, like time stamps.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
ok I usually use commandbuilder and set it to my SqlDataAdapter but not sure about what you are saying with the UPDATE followed by a SELECT(separated by a semi-colon). I don't believe I have seen it done this way yet. Can you give me an example?
Thanks,
JJ
|
|
|
|
|
Use something like the following for your SqlCommand you set as the SqlDataAdapter.InsertCommand :
INSERT INTO MyTable Name VALUES('Name'); SELECT * FROM MyTable; The SELECT statement should actually match the SQL statement you use for your SelectCommand .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
When you called NewRow , you got a DataRow . After you add that, the object reference has not changed. If you don't have that variable that references the DataRow anymore (like it fell out of scope), then you'll have to enumerate your DataTable to find it, or use DataTable.Select with a filter expression (see DataColumn.Expression for syntax) to find it.
This is all well-documented in the class documentation for DataSet , DataTable , and DataRow classes, which you really should read.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how do i plot a graph that looks like the CPU load monitor graph in XP?
I just need the formulae or some code that shows how to do it. I have the data available , and I could easily find my way to plot the graph using the graphics libs.
I'm guessing , this is going to be using some Gaussian noise formulae. But google didnt give me any affirmitive results.
Any ideas ?
|
|
|
|
|
|
A Windows user with regular "user" permissions is running my C# program, and it's not able to access HKEY_LOCAL_MACHINE/Software/Blah
Does that sound right?
What are the permissions rules for HKEY_LOCAL_MACHINE?
Thanks,
Elena
|
|
|
|
|
By default, everyone has permissions to read HKLM, and that's the way it should be. Users should only be able to write changes to their hive (HKEY_CURRENT_USER). If you have user-specific settings, that's where they should go.
Actually for .NET applications, nothing should go in the registry in a typical scenario. You typically use the .config file for application settings. If you have user settings, you can save them in a user's isolated storage (see the System.IO.IsolatedStorage namespace in the .NET Framework SDK). This allows for touchless deployment, or XCOPY deployment as it's sometimes called.
At the very least, your application should be sensitive to the fact that settings in the registry might not exist, using default values or displaying user-friendly errors where appropriate.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to read HKLM, and it's not letting me.
Elena
|
|
|
|
|
If you're getting a specific problem, be specific. What exception is being thrown? If you're handling the exception, then break into your debugger and tell us. "it's not letting me" tells me nothing.
Also, see my other post. If this code is not running from the local machine (or the CAS user policy is more limited), code access security may be preventing the call to the registry class methods.
Finally, I told you what the default permissions are. If you want to know what they are on your machine, then open regedit.exe, right-click on HKEY_LOCAL_MACHINE and select Permissions (if you don't see that, use regedt32.exe instead since this was a new UI feature in recent Windows OSes).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Oh, and one more thing: depending on the source of the executing app, code access security may be preventing calls as well. If the application is running from the Intranet zone, it's granted limited permissions (no registry access at all). For the Internet zone, either no permissions are granted (.NET 1.0) or very few are granted (.NET 1.1).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have created a user control, on which I have place an MDI Client control. I next added my control to a project. Now, I want to open new Forms inside of the Client. Here is my problem:
childForm myChild = new childForm();
mdi1.m.Controls.Add(myChild);
<br />
myChild.Show();
The error occurs here:
<br />
mdi1.m.Controls.Add(myChild); <br />
this is the error:
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Can only add MDI child forms to an MdiClient.
The only way I can currently get around this is to make my main form an MDI Parent, and add this code before adding the form to the user control:
<br />
myChild.MdiParent = this; <br />
Then, when I try to add the form to the user control, it works beautifully. I can only assume that this is because the Form.IsMdiChild property is set to TRUE.
But, I need to do this without first adding it to an MDI Parent (making my main form an MDI Parent.)
So my question is:
1) Is there a way to write to the Form.IsMdiChild value?
or
2) Is there another way to do this?
Hopefully, this problem will interest somebody... Thanks.
Agent 86
|
|
|
|
|
Agent 86 wrote:
1) Is there a way to write to the Form.IsMdiChild value?
Nope. This is a read only property settable at design time only.
Agent 86 wrote:
2) Is there another way to do this?
Nope. You can't have an MDI Parent be a child of another MDI Parent, which is what you are trying to do. A form can either be an MDI Parent OR an MDI Child, but not both at the same time. There is no way around this...
RageInTheMachine9532
|
|
|
|
|
Hi,
I'm trying to create a dataset with an xsd file but get a 'System.InvalidOperationException' when I try to fillSchemain DataAdapter. It's prbably failing because I didn't set a connection to Dataadapter but I don't have a connection to database because this is offline. How can I get the Schema into the dataset? Here's my code:
<br />
DataSet IpacDS = new DataSet("Midnight"); <br />
<br />
try<br />
{<br />
IpacDS.ReadXmlSchema(sXmlFileName);<br />
SqlDataAdapter da = new SqlDataAdapter();<br />
da.FillSchema(IpacDS, SchemaType.Source); <-- Fails here<br />
<br />
<br />
<br />
<br />
|
|
|
|
|
Why are you even trying to do this? FillSchema builds the schema for the DataSet by using the SelectCommand . If you've already got your schema (referenced by sXmlFileName ) and are reading that into the DataSet using ReadXmlSchema , that's all you need to do. Just make sure that schema and what you'd pull from the database (yes, which requires a connection otherwise the schema can't be determined) are the same (or that the latter is a subset of the former).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I solved my problem. If I name the table in the Dataset as something other than MN, it would fail on the line I mention. Why is that so?
Here is the code I used:
<br />
<br />
DataSet IpacDS = new DataSet("MN"); <br />
<br />
try<br />
{<br />
IpacDS.ReadXmlSchema("MN.xsd");<br />
DataRow nRow = dsDiff.Tables["MN"].NewRow(); <- Would Fail here if I didn't name it MN.<br />
<br />
<br />
Any ideas why ?
Thanks,
JJ
|
|
|
|
|
Because no DataTable would be found named "MN", so dsDiff.Tables["MN"] would return null . You can't call NewRow() on null , hence the NullReferenceException you would've received. This is the result of improper checks and exception handling.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
i'd like to sort the child items of a node of a Windows Forms TreeView control using a function of my own that set if the node is to be listed before or after another. Every node has a logic code that i've stored internally using a derived class of TreeNode and i'd like to sort the item by this one.
In MFC there's the possibility of defining a logic compare function, is there anything similar in .NET? Or there's another way to add a new child node of an item and sort all its childs without removing them and reloading ?
Thanks,
Gianmaria
|
|
|
|
|