|
And so is the more compact alternative:
var result = Regex.Replace("+^%{}", @"\+|\^|\%|\{|\}", "{${0}}");
var result = Regex.Replace("+^%{}", @"[\+\^%{}]", "{${0}}");
EDIT: Compacted further
|
|
|
|
|
aspdotnetdev wrote: @"\+|\^|\%|\{|\}"
I suppose this could be a little more compact, what with all the unnecessary escaping.
|
|
|
|
|
hi friends,
i am using a panel of which i want to increase the size to maximum of may be 20,000 X 20,000
how can i achieve this on runtime? It gives me error like
System.ComponentModel.Win32Exception: The operation completed successfully
at System.Windows.Forms.DibGraphicsBufferManager.CreateCompatibleDIB(IntPtr hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
at System.Windows.Forms.DibGraphicsBufferManager.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height) etc..
actually i am working on zooming of image.. i am calculating the zoom percent and just increasing the width and height of panel and redrawing the image on it.. this works fine ..but when my panel size is set to above 12,000 X 8000 the system gives the above error..
thanks in advance
Samir
|
|
|
|
|
I just experimented subclassing Panel and it worked OK for me.
public class MyPanel : Panel
{
public static readonly Size DefaultMaxSize = new Size(20000, 20000);
protected override Size DefaultMaximumSize
{
get { return DefaultMaxSize; }
}
}
MyPanel myPanel = new MyPanel();
myPanel.Size = myPanel.Size = MyPanel.DefaultMaxSize;
Console.WriteLine(myPanel.Size);
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Try to disable double buffering, if you enable it.
It seems that Control class (and its subclasses) tries to create a bitmap as a back buffer of same size as the control.
|
|
|
|
|
Hey guys,
I have a MDI Windows app. The MDI Parent has a MenuStrip control with a few menu options
File > Merge index 1
- New > Merge index 101
- Open > Merge index 102
- Seperator > Merge index 198
- Exit Application > Merge index 199
I have a second form which is opened as MDI Child of the parent described above containing a MenuStrip as well and having the following menu items :
File > Merge action MatchOnly
- Seperator > Merge index 110 & MergeAction Insert
- Save > Merge index 111 & MergeAction Insert
- Save As > Merge index 112 & MergeAction Insert
The MenuStrip's Visible property is set to 'false'.
Now when I run my app, the parent's menu is displayed, everything fine. When I open the child window, the items Seperator, Save and Save As are neatly merged into the File menu of the MDI Parent, however the items are not ordered using the Merge Index, the items are appended at the bottom of the menu. How can I make the menu strip work with the Index so the menu items order is right?
Thanks for the help, keep up the good work!
|
|
|
|
|
I have a User control that contains three radio buttons - rbCirc, rbRect, and rbTrap - representing 3 possible shapes, and three textboxes for user values. I'm used to programs that automatically advance to the next item in the tab order when I press Enter, but I haven't been able to duplicate that behavior. Tab works as expected, but Enter just makes a "Bonk" sound, at least in the debugger. What can I do to make the focus advance when a user presses Enter?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
In the KeyDown event for the form, see if the key hit is enter and if so, write code to proceed
|
|
|
|
|
I do not know how to avoid sound.
But you can achieve the behavior by tracking keypress event
private void radioButton1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
Yourcontrol.Focus();
}
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Thanks, Jinal! It works great!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hy,
Use the KeyDown event and compare:
if(e.KeyCode == Keys.Enter){
e.Handled = true;
e.SupressKeyPress = true;
txtYouNameIt.Focus();
}
Something like that should work
Just an irritated, ranting son of ... an IT guy.
At your trolling services
|
|
|
|
|
Thanks! This is a little more general solution, and good for a User Control intended for re-use.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
np
Just an irritated, ranting son of ... an IT guy.
At your trolling services
|
|
|
|
|
Hi Roger,
The answers give already, work perfectly well in circumstances where you know the Name of the control that you want to go to and are prepared to write an individual KeyDown /Keypress (select your poison) handler for each control. However, for circumstances where you want to simply follow the TabOrder you have already set and, where applicable, use one handler for several controls, the System.Windows.Forms.Control class has a built in method to do exactly what you want. Look up the System.Windows.Forms.Control.GetNextControl() method.
An example:
private void Comunal_KeyDownHandler(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
this.GetNextControl((Control)sender, true).Focus();
}
}
This way you can assign the handler to all the controls in your User Control, provided that you are not already using their KeyDown event for something else.
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
Everything already said will work, but you might also want to consider the "KeyPreview" property of the Form.
This lets the Form see the key-press before it goes to any controls, so it allows you to create a handler at the Form level instead of a handler for each individual control.
Another advantage is that all your code will be inside a single handler instead of spread out among all the various controls.
|
|
|
|
|
Hello,
I would like to bin and zero-fill excel or text data using C#.
For example;
Raw data:
1 34
2
3 43
4 3
5
converted to:
1 34
2 0
3 45
4 3
5 0
Does anyone have code for this?
Thanks
|
|
|
|
|
Couldn't you just format the column to be a number that was an empty cell would display 0?
|
|
|
|
|
For text data, look for lines that don't contain an embedded space, then append " 0":
public List<string> CleanupText(List<string> inputLines)
{
List<string> outputLines = new List<string>();
foreach (string s in inputLines)
{
if (s.Trim().Replace('\t', ' ').Contains(" "))
outputLines.Add(s);
else
outputLines.Add(string.Concat(s, " 0"));
}
return outputLines;
}
If you want to modify the collection in place, you'll have to replace the foreach() with a for() and an index into the list - since foreach() loops disallow modifying the collection they are iterating.
To do this with Excel you'll have to iterate rows (the end condition being a cell in the first column that is empty), looking for cells in the 2nd column that are blank and inserting a '0' into those blank cells. I've not done enough MSOffice interop to be able to give you a code example.
|
|
|
|
|
Hi!
I have a question. I have two forms, Form1 and Form2. I add two textboxes to form1 and the same with form2 I fill in the textboxes on form1 and save the information to sql templatetable1.
I need to display a list of entries from form1 in a dropdonwlist and when the user selects an entry, form2 needs to be populated by the selected template.
How can I do this?
Illegal Operation
|
|
|
|
|
Assign the control to a new control in form2
|
|
|
|
|
|
my application is working properly on windows xp with both office 2003 & 2007
but when i am trying to run it on windows 7 an error message came up,
everything is ok. forms and reports, only creating an Excel file is giving the error.
i installed PIAs for office 2007 but i still have the same problem.
anybody can help me.
the error message is can not load library/dll. com object Excel
thanks in advance
|
|
|
|
|
This is vague.
It could be many things such as security permissions or 64 bit problem or...
Compile your app explicitly for x86. And try again.
Also try running as a admin.
Just an irritated, ranting son of ... an IT guy.
At your trolling services
|
|
|
|
|
if it is a exe, try right-clicking on it and select "run as administrator".
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Hi Everyone, I have an application that has at least two forms and a Class. how do I access variable between two forms without initializing all varialbes each time I access the class.
this is how I access functions form the Class
In Form1 I do this:
ClassA myClass = new ClassA();
myClass.Function_A();
// do something with it.
IN Form2
ClassA myClass2 = new ClassA();
myClass2.Function_B();
// do something with it.
how do i prevent ClassA funtions from reinitializing all over again. I want to treat the ClassA's funtions and variables like Global variable.
Thanks
"Show me the way I will get there"
|
|
|
|