|
As I said keep it in a viewstate.
|
|
|
|
|
thank you so much
for ur idea
i m a new to C#.net
it helped me a lot
|
|
|
|
|
Does any one know the units of time used by the ToBinary
method of DateTime? For example
long start = DateTime.Now.ToBinary();
Sleep(1000);
long elapsed = DateTime.Now.ToBinary()-start;
The variable elapsed will be in the range of 10,000,000.
What does this value represent? Is it tenths of a micro
second or some other unit of time?
Thanks
James johnson
|
|
|
|
|
WBurgMo wrote: The variable elapsed will be in the range of 10,000,000.
I am not sure it will be in this range. Value you are getting is a signed 64-bit number.
WBurgMo wrote: Is it tenths of a micro
second or some other unit of time?
Here is what MSDN says,
Serializes the current DateTime object to a 64-bit binary value that subsequently can be used to recreate the DateTime object.
|
|
|
|
|
Hi everyone,
Would that be possible, after I opened two MS word documents then it will read through the documents and generate a report which explains the difference between these two, for instance: Paragraphs, Words, Sentences, Tables and Pages -> which were easily obtained from the object.
And bring that further, would that be possible to count how many images and display styles used inside a particular document too?
One of the scenario is, if obtaining styles name is possible, when a particular style is selected, it will highlight the text/paragraph which use the styles.
Have any idea?
Many thanks in advance
|
|
|
|
|
Yes, it's all possible. Sounds like a fair bit of work. Tools that just compare two plain text files sell for $300, so that should tell you something.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
I've created a class to hold some variables that I need to maintain and use across two Paint event handlers. They are filled in by one paint event and used in another. If I set a breakpoint at the end of the paint event that fill in the data, wait for it to stop, then clear it and continue everything is there and the 2nd paint handler works fine. If I run the program straight through without the break I just mentioned then all of the fields are set to zero when the 2nd paint handler gets them. I'm relatively new to C# so this is probably a dumb error I've wandered into. How can I define these variables so that they are maintined intact for the life of the program and will be accessable by both paint handlers for the form?
namespace gradientshapebuilder<br />
{<br />
public class mv<br />
{<br />
public static double[] depthMap = new double[256];<br />
public static double refDepth;<br />
public static int maxDepthIdx;<br />
}<br />
}
This is how I set them
mv.refDepth = cube[0].Y - cube[3].Y;<br />
mv.depthMap[mv.maxDepthIdx] = current.Y -cube[3].Y;<br />
mv.maxDepthIdx = mv.maxDepthIdx + 1;
and how I use them in the 2nd paint handler
grayScaleInt = Convert.ToInt32(255.0 * ( mv.depthMap[i])/mv.refDepth);
|
|
|
|
|
If you want one set of variables that is visible across the program, you need one static instance of this class. If your instances are not static, then they are disreet from each other.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Do you have the two paint event handlers in same class? If yes, make object of mv as a class level variable. So that it will be available until the lifetime of the class. Else as Christian said, make the class as static. So it will be available until the application domain unloads.
|
|
|
|
|
N a v a n e e t h wrote: Do you have the two paint event handlers in same class?
Is that even possible ? I guess you could have paint event handlers for differnt controls on a form ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
With the same name it is not possible. But it can have multiple handlers with different names, right? Also as you said paint event handlers for different controls is also possible.
Not sure what OP exactly meant by that as he hasn't explained anything about that.
|
|
|
|
|
I kind of started to post and then realised you could have handlers for controls within a form. So I was kind of talking to myself :P
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I tried making the mv class static and even moved the variables back to the form class setting them up as static as well. Neither of those ideas worked. What finally worked, though I don't know why, is to put
this.bitmapBox.Invalidate();
just before the exit of the paint event that fills the array and other variables. This caused a repaint of the second picturebox. The data was still around at that point and the bitmap was built correctly.
|
|
|
|
|
I wonder if there is a way to keep my application settings after version is changed (with AssemblyVersion).
.NET framework is creating separate folder to store .config file for each version of application, so user should enter all configuration in GUI once upgraded to newer version.
|
|
|
|
|
Take a look at the documentation for ApplicationSettingsBase.Upgrade . Make sure to follow all the links, there is a lot of information to assimilate. For individual settings the ApplicationSettingsBase.GetPreviousVersion method is useful.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have built a typed dataset which is Filled by SqlDataAdapter. The dataset has two tables (parent and child) with relationship using multiple columns (composite). The end objective is to replace this relationship with a dynamically generated one as some of the columns for both the parent and child table will be added at runtime and will be used as part of the relationship. The typed dataset has expressions defined, requiring me to have a relationship defined in advance.
The tests I have done ignores the dynamic columns and has fixed ones defined on the typed dataset that match the resultant query/recordset. The code replaces the existing relationship with an _exact_ copy using the same columns and relationship name as before (even having the parent/child relationship columns in the same order). The swap works fine but when I get to fill the dataset it throws the following exception:
<br />
System.ArgumentException: The row doesn't belong to the same DataSet as this relation.<br />
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos, Boolean fireEvent)<br />
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos)<br />
at System.Data.DataTable.AddRow(DataRow row, Int32 proposedID)<br />
at System.Data.DataTable.AddRow(DataRow row) .. blah blah blah<br />
The only difference I can tell between the old relationship and the new is their HashCode (obviously) and that the old relationship still has a reference to the parent and child tables (as MS likes bi-directional dependencies).
Puedo Code:
<br />
var dataSet = new MyDataSet();<br />
var parentTable = dataSet.Parent;<br />
var childTable = dataSet.Child;<br />
<br />
var relationshipName = "myrelationshipname";<br />
var oldRelationship = dataSet.Relations[relationshipName];<br />
<br />
dataSet.Relations.Remove(oldRelationship);<br />
<br />
var parentColumns = new List<DataColumn>();<br />
var childColumns = new List<DataColumn>();<br />
<br />
parentColumns.Add(parentTable.Columns["Column1"]);<br />
parentColumns.Add(parentTable.Columns["Column2"]);<br />
<br />
childColumns.Add(childTable.Columns["Column1"]);<br />
childColumns.Add(childTable.Columns["Column2"]);<br />
<br />
dataSet.Relations.Add(relationshipName, parentColumns.ToArray(), childColumns.ToArray(), false);<br />
<br />
this.FunctionToFillDataSet(dataSet, query);<br />
The above (real) code works fine if I don't remove / add the relationship.
The Original Relationship is setup for "Relation only" and not "constraints". When I add the new relationship, I use the overload to disable constraints ... DataSet.Relations.Add(relationshipName, parentcolumns[], childcolumns[], false) which I take as the same as "Relation only" from the first relationship.
I have searched all over trying to find someone with this problem. Most reference not adding the relationship which is clearly not the case here.
I'm on a strict schedule and having to go to my alternative will mean me having to drop the typed dataset all together and create my expressions and columns completely at runtime which I'd rather not do. We're a .net 2.0 environment. Development is under VS2008.
Any help would be greatly appreciated.
Thanks.
modified on Wednesday, August 26, 2009 8:44 PM
|
|
|
|
|
I am developing a C# Windows Application which inserts data into a SQLCE database.
It inserts fine, that works great!
However, if i want to select the new record from the database, it comes back as a blank result. I can search for previous records before i opened the applications. Its as though the database opens a cached copy, and you can only insert into it.
Here is my current code. Has anybody else had similar issues.
private void button2_Click(object sender, EventArgs e)
{
if (txtAddRegistration.Text != "")
{
if (comboAircraft.Text != "")
{
if (comboAirline.Text != "")
{
if (comboLocation.Text != "")
{
int picyesorno;
string picloc;
if (txtAddPicLoc.Text == "")
{
picyesorno = 0;
picloc = "";
}
else
{
picyesorno = 1;
picloc = txtAddPicLoc.Text;
}
string InsertRegCommand = "INSERT INTO SPOTTINGLOG (registration, aircraft, airline, location, date, pictured, picloc, comments) values('" + txtAddRegistration.Text + "','" + comboAircraft.Text + "','" + comboAirline.Text + "','" + comboLocation.Text + "'," + dateTimePicker1.Value.ToShortDateString() + "," + picyesorno + ",'" + picloc + "','" + txtAddComments.Text + "')";
string database = @"D:\Daniel\Documents\Visual Studio 2008\Projects\AviationSpottingLog\AviationSpottingLog\SpotData.sdf";
try
{
SqlCeConnection conn = new SqlCeConnection("Data Source=" + database);
conn.Open();
SqlCeCommand command = new SqlCeCommand();
command.Connection = conn;
command.CommandText = InsertRegCommand;
command.ExecuteNonQuery();
conn.Close();
}
catch
{
}
try
{
this.searchAfterAdd(txtAddRegistration.Text);
}
catch
{
MessageBox.Show("Search didnt work");
}
txtAddComments.Clear();
txtAddPicLoc.Clear();
txtAddRegistration.Clear();
comboAircraft.Text = "";
comboAirline.Text = "";
txtLabelAdded.Text = "Added";
AddStatus.Start();
}
else
{
MessageBox.Show("You must enter a location.", "Insert Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("You must enter an airline.", "Insert Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("You must enter an aircraft type.", "Insert Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("You must enter a registration.", "Insert Record", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void searchAfterAdd(string param)
{
this.spottingLogTableAdapter.Fill(this.spotSearchReg.SpottingLog, param);
}
private void btnSearch_Click(object sender, EventArgs e)
{
if (txtSearchReg.Text != "")
{
this.spottingLogTableAdapter.Fill(this.spotSearchReg.SpottingLog, txtSearchReg.Text);
}
else
{
MessageBox.Show("Please enter a registration to search for.\n\nIf you would like to view records for specific Airports, Airlines and Aircraft, go to 'Browse Data Lists' on the top menu.", "Enter Search Criteria", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
Hi All,
I created a simple application in C# that displays a message when a button is clicked. I want this app. to be updated from a network drive, the same network drive that it was published from using ClickOnce.
In the Publish --> Updates window of the apps properties, it's set up so updates are checked "before the application starts".
After a modification is made to the application and I re-publish it the updated files are sent out to the users machine along with an updated very of the setup.exe file.
However, when the user starts the application from the start menu they aren't informed that an update is available and the old version of the application is ran.
The start.exe file can be ran and the new version installed then, but this isn't what I want the user to have to do. Shouldn't the user be informaed of the updated version when the app is ran?
Any ideas would be greatly appreciated.
Thanks,
Mel
|
|
|
|
|
Don't cross post, you've already asked this question in another forum. Wait for someone to respond.
only two letters away from being an asset
|
|
|
|
|
Hello everyone,
I am having trouble with UdpClient class. Here is my code:
private UdpClient myClient;
private void button1_Click(object sender, EventArgs e)
{
myClient = new UdpClient(7777);
}
private void button2_Click(object sender, EventArgs e)
{
myClient.Close();
}
So when I press button1 to connect for the first time - Everything is OK
when I press button2 to discconect - Everything is OK
But when I try to connect for the second time by pressnig button1 I get the error : "Only one usage of each socket address (protocol/network address/port) is normally permitted"
How can I solve this problem? How can I bind my socket again? Any help will be appreciated.
Regards
|
|
|
|
|
The error comes only if you press button1 2 times.
If you press button1, button2, then button1 again, it's ok.
|
|
|
|
|
Why do you want to press button twice? When UdpClient 's constructor is executed with a port number, it binds to the port number provided. You can't rebind to that port again. Once the binding is done, call Connect() method to connect the socket.
|
|
|
|
|
We have a DataSet with Table Adapters built for MSAccess using OLEDB. We are using Visual Studio 2005 and .Net 2.0.
When the designer creates insert, update and delete queries it encloses the table name and field names with a ` (ASCII char 96).
For example:
INSERT INTO `table` (`col1`, `col2`, `col3`) values (...)
Is there a reason for this character? Assuming it's for escape purposes, is there a setting to make Visual Studio use another character, eg "[" or "]"?
If there is no setting, is there a way to intercept the way the designer creates these queries?
|
|
|
|
|
I am not sure how to remove it and character [ is valid for MS access. What issue are you facing with these characters?
|
|
|
|
|