|
thanx..
so this would not work for excel then?
is there a reason i should make hdr = no?
Nothing lasts but nothing is lost
|
|
|
|
|
Hi again
i solved it, the connection string was fine, i had to add the excel 12.0 object library..
my bad, weak mistake on my behalf
thanx again
Nothing lasts but nothing is lost
|
|
|
|
|
Hi
I have sample MDI application with two these forms :
Form1(Main Form) is MdiParent
Form2 is MdiChild
i want when Form2 open, it should be Maximize and user can't change it's WindowState, for this, i wrote this code to open Form2 :
Form2 frm;
frm.MdiParent = this;
frm.Show();
Form2 Designer Code :
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 268);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form2";
this.Text = "Form2";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
But, in runTime (as u see in above designer code which Maximize and Minimize set to False), when i open Form2, the Maximize and Minimize appear in Form2 and when click on Maximize button, it's WindowState change to normal (which i don't want this).
Where does my problem and how to solve it ?
Thanks
|
|
|
|
|
I didn' realize at the time but I have an MDI app and when I set minimize and maximize to false
MY APP DID THE SAME THING!
I did a bit of looking around and came up with this
Put the code below in the forms resize event and this will prevent the form minimizing
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Maximized;
}
If the form reverts to "normal mode"
add this as well TO THE SAME resize event handler this will prevent the form going to normal mode
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Maximized;
}
The top code block detects "minimized state", if so then maximise.
The bottom code block detects "normal state", if so then maximise.
I DONT SEE WHY THIS SHOULD NOT WORK BUT I HAVE NOT TRIED THIS SO I CANT VOUCH FOR IT
|
|
|
|
|
First of all, I know the standard answer to this question is "If you need to know, you're doing it wrong", but I really do need to know!
Long story short, I have a caching mechanism in a web service (IIS 6) that can cache thousands of items in memory and return them almost instantly, without requiring a trip to the main datastore.
However, when the cached items expire they need to be refetched from the datastore, but only one caller can be executing the 'fetch' code at a time (or else it runs into all sorts of horrible race conditions and deadlocks). All the other callers must either wait for the first thread to update the cache (if the item is not found in the cache) or simply return the cached item while it is being updated in the background.
Each data item contains its own ManualResetEvent, which it uses to block while the cached item is updated. By giving each dataitem its own ManualResetEvent, I can allow other data items to be fetched without blocking them - the only calls that are blocked are those for the *exact* item that has expired.
My concern is that I will run out of handles for the data items, since each item has its own ManualResetEvent, and there could potentially be tens of thousands of data items. Do I need to worry about this, or should I try to come up with an alternate implementation?
Perhaps I could use a pool of ManualResetEvents that can be assigned to items as needed, similar to the way database connection pooling works? This is probably a "better" implementation, but it is more complex and harder to debug...
Thanks for your help
modified on Tuesday, April 14, 2009 4:14 PM
|
|
|
|
|
Miszou wrote: If you need to know, you're doing it wrong
I'm afraid you proved it true once more.
I don't know the number (I must be doing something right ), AFAIK it is a fixed number that depends on the Windows version and I expect it does not exceed a few thousand on a client version.
As each caller may be waiting and causing one update at most, why not associate a ResetEvent with each caller (=each thread) instead of with each handler?
You can use a Dictionary if you want an automatic association, and you can create the ResetEvent when an entry is not found; you could optionally provide a CreateEvent() method so the ResetEvent and DictionaryEntry can be created in advance.
IMO this scheme looks simpler and more deterministic than a pooling scheme.
|
|
|
|
|
Luc 648011 wrote: I'm afraid you proved it true once more.
Haha, yeah I was afraid of that!
I like your idea of associating the ResetEvent with the caller - as you say, it's a lot simpler than a pooling scheme and much safer than risking the handle limit.
I think I've been looking at the forest for so long that I couldn't see the trees!
Thanks for the help.
|
|
|
|
|
There is a registry key for this, you could check it.
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERProcessHandleQuota
It is set to 10k on my machine, which runs XP x64 pro.
|
|
|
|
|
Hi,
I am about to start a visual studio 2005 project to create a C# class library, however, I have seen that some people uses the COM/COM+ components and they develop their libraries under COM/COM+ architecture ... they see the COM component in "Component Services" and the process as well when it is running.
I am wondering ...
What are the "pros and cons" of using COM/COM+ ? (over the standard default class library dll)
Thanks,
|
|
|
|
|
Hi,
COM offers component architecture inside and outside .NET (you can use COM from VB6 ).
COM needs extra code and care, installation, registration, has appartment issues, ...
as I always use .NET on PC, I avoid COM.
|
|
|
|
|
Thanks for the reply, I guess the only usage of COM/COM+ nowdays is to use managed code .NET from unmanaged code (VB6 for example)
Would microsoft leave this architecture in the future?
Regards,
|
|
|
|
|
IMO they seldom leave something, they may shift their focus...
|
|
|
|
|
Hi
I'm just wondering could anyone give me some pointers on where I could find how to share data between two different processes in c# at first but I might make a c++ version after when I get more experience in it. I have found two articles here on codeproject but I'm finding them a little hard to understand
article 1
article 2
If you could help it would be great
|
|
|
|
|
Hi ppl
Pls help me with a cell change problem.
I have a sourcegrid with 4 column ans 4 rows.
I can Insert data to every cell but the problem is I dont wanna use mouse or Tab to change cell. I want to use Enter key to change cell.
That mease I will insert data to a cell and press Enter key and coursor will go to next cell.
Can anyone have face this problem....
please help me
Thanks
|
|
|
|
|
SourceGrid - Open Source C# Grid Control[^]
I presume that^ is the source grid you're on about.
Something like this should work
void grid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (grid1.FocusCell.Row == grid1.RowsCount-1)
{
if (grid1.FocusCell.Column == grid1.Columns.Count - 1)
{
grid1[1,0].Focus(); selects the first cell
}
else grid1[1, grid1.FocusCell.Column + 1].Focus();selects the first cell in the next
}
else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();
}
}
|
|
|
|
|
many many thanks.
I have tried it but some error I cant understand...
void grid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (grid1.FocusCell.Row == grid1.RowsCount-1)
//to check if you have reached the last cell in the column
{
if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the
//last row in the last column
{
grid1[1,0].Focus(); //selects the first cell
}
else grid1[1, grid1.FocusCell.Column + 1].Focus();//selects the first cell in the next
//column
}
else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell
}
}
The Bold text "grid1.focuscell.row and grid1.focuscell.colume does not have any defination."
Cant you fix it pls
Thanks
modified on Tuesday, April 14, 2009 10:18 PM
|
|
|
|
|
put your source grid name ("grid1" change it to your grid name") there my friend.
I think you better use the key up event, that can easly handle enter or arrow keys.
|
|
|
|
|
Sorry that was my fault
You must be using version 4;
try this way:
void grid1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int row = grid1.Selection.ActivePosition.Row;
textBox1.Text = row.ToString();
int column = grid1.Selection.ActivePosition.Column;
if (grid1.Selection.ActivePosition.Row == grid1.RowsCount - 1)
{
if (column == grid1.Columns.Count - 1)
{
grid1.Selection.Focus(new SourceGrid.Position(1, 0), true);
}
else grid1.Selection.Focus(new SourceGrid.Position(1, grid1.Selection.ActivePosition.Column + 1), true);
}
else
grid1.Selection.MoveActiveCell(1, 0);
}
}
|
|
|
|
|
Sorry I was out of town.I have tried it but
It didnt work. Dont know why.
Do I need to use any event handler code to the .Designer.CS page?
Like this.grid1.keypress += new .....
pls make it clear.
Thanks again
modified on Saturday, April 18, 2009 11:24 AM
|
|
|
|
|
Hi
I have 2 Windows Service Question
1.Is WS can work in background ? Is it posible to do some job evry 2 minutes ? (if yes, can I get some help ?)
2.How can I install WS in simple way ? (not with Installutil.exe .......)
3.How to run .exe file through WS
i'll do this:
System.Diagnostics.Process G = new Process();
G.StartInfo.FileName = @"d:\demo.exe";
G.Start();
thank's in advance
|
|
|
|
|
1. Yes, absolutely. Use the System.Threading.Timer class. Read the documentation for the choices that are offered to you.
2. Installutil.exe is the best way. You may try to use a setup project instead, but I never tried it.
3. This seems to be correct to me.
E_Gold wrote: I have 2 Windows Service Question
You should learn how to count, that was 3 questions.
|
|
|
|
|
1) Yes. Avoid the Timer class and write a threaded timer.
2) You can't not use installutil.exe...
3) Use the Process class.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I use a System.Timers.Timer
|
|
|
|
|
You get more control with a thread, and the timer events are the lowest priority events in Windows. This means that on a busy system, your app might not even *see* the event. Personally, I take no chances with that kind of stuff.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Well then it depends on usage; the Timer does what I need it to.
|
|
|
|