|
Doesn't matter, just copy 20 characters.
I actually tried to just adding random letters on the end, it still worked.
|
|
|
|
|
Thanks a lot hammerstein05.
Freshman
|
|
|
|
|
MDI WinForms 2 application.
I need that Ctrl+F1 cycles through windows like Ctrl+Tab.
I overrided MDI child form OnKeypress method but Ctrl+F1 press is ignored.
How to force Ctrl+F1 to cycle between windows ?
Andrus.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Control | Keys.Tab:
return true;
case Keys.Control | Keys.F1:
keyData = Keys.Control | Keys.Tab ;
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Andrus
|
|
|
|
|
If focused control is ReadOnly, Ctrl+E menu shortcut key is ignored.
To reproduce, run code below, press Ctrl+E.
Message box does not appear.
How to use Ctrl+E key from readonly or disabled control ?
Andrus.
using System;
using System.Windows.Forms;
static class Program
{
static void Main()
{
Application.Run(new Form1());
}
}
class Form1 : Form
{
public Form1()
{
menuStrip1 = new MenuStrip();
fileToolStripMenuItem = new ToolStripMenuItem();
openToolStripMenuItem = new ToolStripMenuItem();
textBox1 = new TextBox();
menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem });
fileToolStripMenuItem.Text = "File";
openToolStripMenuItem.ShortcutKeys = ((Keys)((Keys.Control | Keys.E)));
openToolStripMenuItem.Text = "Open";
openToolStripMenuItem.Click += new System.EventHandler(openToolStripMenuItem_Click);
textBox1.Location = new System.Drawing.Point(55, 150);
textBox1.ReadOnly = true;
Controls.Add(textBox1);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
}
void openToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Clicked");
}
MenuStrip menuStrip1;
ToolStripMenuItem fileToolStripMenuItem;
ToolStripMenuItem openToolStripMenuItem;
TextBox textBox1;
}
Andrus
|
|
|
|
|
I am using Sql Server 2005 Compact Edition as a database and I can't seem to get this thing to add a simple record... I run the a simple Insert statement and the Table is still empty. I get no error code or anything... Has anyone else been able to add records to a Compact Edition table in Visual Studio 2005 using C#??? Here is my code...
INSERT INTO TimeZone
(state, abbrev, tzone)
VALUES (@p1, @p2, @p3)
Now the one thing that isn't showing is my primary key field which is "tzid". But it is autonumbered. I fill in the values in code for @p1, @p2, @p3. When I open up the TimeZone table, it is empty... Any help would be appreciated. Thanks
|
|
|
|
|
I've no experience with CE but are you able to execture your query with your parameters from a Management Studio?
|
|
|
|
|
please put your code over here
|
|
|
|
|
Is it possible to get the left-most coordinate (the left edge of the Region) for a specific y-coordinate? I thought about getting the bounds for the Region, then start at the x-coordinate and work my way in with IsVisible(), but it's very slow. Does anybody have any other ideas?
Thanks!
|
|
|
|
|
If you can't divide the bounds of the region into lines (so that you can use simple linear math to calculate the coordinate), you can use a binary search to call IsVisible as few times as possible.
Pick two points, one that you know is to the left of the region, and one that you know is inside the region. Calculate the point that is exactly in the middle of those two points. Use IsVisible to find out if that point is inside the region or not. If it is, use that as the new rightmost point, otherwise use it as the new leftmost point. Repeat the process until the distance between the points is small enough.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
I haven't done this, but I would expect the region class to have methods to solve this.
How about intersecting with a rectangle (height 1), then call GetBounds?
|
|
|
|
|
Thanks! I'll go with the latter one. I hadn't thought of that :> brilliant! thanks.
|
|
|
|
|
Hi
The pattern is sth like this:
<br />
^-?((?<X>[0-9]{0,8})/(?<Y>[0-9]{0,15})|(?<X>[0-9]{0,8}))\*?$<br />
and I want to have the variables in their named groups as following
X=...
Y=...
I don't know how to use MatchCollection, CaptureCollection ,etc. Can anyone help me?
|
|
|
|
|
A good starting point would be MSDN help That section is extensive and pretty well written.
Let's start with a simpler pattern. Once you get it working you can make it more complex.
Suppose your pattern is smth like the following: (?<var1>\w+)
"var1" is the name of your capture
Regex r = new Regex(patter<, RegexOptions> );
MatchCollection mc = r.Matches(your_text_to_match);
if (mc.Count > 0)
{
}
Well, something along these lines anyway, I'm typing it from the memory, can't check the syntax on the home pc.
|
|
|
|
|
// get the value with: mc[i].Groups["var1"].Value;
Thanks a lot, that was so useful
modified on Wednesday, June 25, 2008 1:50 PM
|
|
|
|
|
another site that has helped me a lot in the past is
http://www.regular-expression.info/[^]
they even have a tool that you can use to quickly test your regex's
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I writea easy loop like below:
for( int i = 0 ; i < 10 ; i ++)
{
Console.WriteLine( System.DateTime.Now.Ticks );
}
the result is always is
633500324611875000
633500324611875000
633500324611875000
633500324611875000
633500324611875000
.......
Can anyone tell me why ? why it always the same ?
|
|
|
|
|
because For statement is very quick.
try it :
for (int i = 0; i < 10; i++)
{
Console.WriteLine(System.DateTime.Now.Ticks);
Thread.Sleep(1000);
}
Console.ReadKey();
Freshman
|
|
|
|
|
thanks, its export different value right now, but the result below:
633500343525625000
633500343526562500
633500343527656250
633500343528593750
633500343529687500
633500343530625000
633500343531718750
is the unit of tick is 50? I guess by the result. thanks
|
|
|
|
|
Hi,
you may find details on timing in my timers article.
|
|
|
|
|
matthew_net wrote: is the unit of tick is 50? I guess by the result. thanks
It's hardware dependent. Not all machines will tick at the same rate, so you shouldn't use it to control anything that needs to run at a fixed rate.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Ticks is only updated a few dozen times per second. If you need higher precision timers they're available. IIRC down to the millisecond level but to try and control your app at that level (as opposed to for logging) you'll pay a major price in CPU utilization since getting it hammers the kernal because windows was never intended as a realtime OS.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
thanks for your patience and kind for my pool English, I think i need to study English more hard, thanks you advice.
|
|
|
|
|
hey guys...
please consider the following code...
private int fpsCounter = 0;
private string fpsString = "0";
public myControl()
{
InitializeComponent();
animationTimer.Start();
fpsTimer.Start();
}
private void clockPanel_Paint(object sender, PaintEventArgs e)
{
fpsCounter++;
drawData(e.Graphics, clockPanel.ClientRectangle);
drawClock(e.Graphics, clockPanel.ClientRectangle);
}
private void fpsTimer_Tick(object sender, EventArgs e)
{
fpsString = fpsCounter.ToString();
fpsCounter = 0;
clockPanel.Invalidate();
}
private void animationTimer_Tick(object sender, EventArgs e)
{
calculateAndUpdateDrawingVariables();
clockPanel.Invalidate();
}
Questions
1. Will this give me an accurate frames per second reading?
2. the reading i get is +/- 100(which makes sence cuz 1000 / 10 = 100), but when the animation timer is set to 1ms the fps value is +/- 500. Is this because the image cant be drawn/calculated that fast and the image wont repaint again until previous panel.Invalidate() has not been completed?
3. quite a bit happens in calculateAndUpdateDrawingVariables(); and it runs 100times per second(animationTimer = 10ms). Any tips on what to avoid in a method like this that runs so many times to use less CPU power?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: 1. Will this give me an accurate frames per second reading?
Probably not, but it will be close.
HarveySaayman wrote: 2. the reading i get is +/- 100(which makes sence cuz 1000 / 10 = 100), but when the animation timer is set to 1ms the fps value is +/- 500. Is this because the image cant be drawn/calculated that fast and the image wont repaint again until previous panel.Invalidate() has not been completed?
Your monitor is not gonna show you more than 60 times a second, going above 60 FPS is pointless (unless you are benchmarking, but then you shouldnt be painting to the screen, but a bitmap instead).
HarveySaayman wrote: 3. quite a bit happens in calculateAndUpdateDrawingVariables(); and it runs 100times per second(animationTimer = 10ms). Any tips on what to avoid in a method like this that runs so many times to use less CPU power?
Can you cache the result of the function given the same variables? If so, that would help. Else redesign you painter so that it can use a cache.
|
|
|
|
|
leppie wrote: Your monitor is not gonna show you more than 60 times a second
Not necessarily true. IF he's using an old CRT he could be running at 100+ FPS. Also there're a handful of LCDs that can run at a native 75hz as a gimic to fool noobs who think it matters like with a CRT.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|