|
If you are running SQL Server in a UNIX environment it is.
only two letters away from being an asset
|
|
|
|
|
I thought of a nice way to clear all textboxes in an application: run a loop from 0 to Controls.Length (because Controls is the array that contains all the controls in the form) and check that if the control is a textbox then clear it...the problem is how do i check it?
I tried stuff like if (Controls[i] == TextBox) and similar stuff but nothing worked. how can i do it then?
|
|
|
|
|
hi
try this:
<br />
foreach (Control c in Controls)<br />
{<br />
TextBox t;<br />
if ((t = c as TextBox) != null)<br />
{<br />
t.Text = "";<br />
}<br />
}<br />
Greets
M@u
|
|
|
|
|
foreach (Control c in Controls)
{
if (c is TextBox)
{
(c as TextBox).Text = "";
}
}
life is study!!!
|
|
|
|
|
thx for the help you all :P
btw, better way
for (int x = 0; x < Controls.Count; x++)
if (Controls[x] is TextBox)
Controls[x].Text = "";
|
|
|
|
|
Hello,
sharpiesharpie wrote: btw, better way
I don't agree with you at all.
It only works because Text is a member of Control, if you later need a member of Textbox you would have to change your code again.
I would take the first solution "m@u" posted, (with the "as" conversion and "!=null" check)
sharpiesharpie wrote: if (Controls[x] is TextBox)
Controls[x].Text = "";
Two access over an indexer is also not a "better way".
All the best,
Martin
|
|
|
|
|
I have a groupbox which contains some groupboxes in it, the following code will clear all textboxes in the groupbox and in the groupboxes in it:
<br />
if (this.Controls[i] is GroupBox)<br />
{<br />
for (int m = 0; m < Controls[i].Controls.Count; m++)<br />
{<br />
if (Controls[i].Controls[m] is TextBox)<br />
Controls[i].Controls[m].Text = "";<br />
<br />
if (Controls[i].Controls[m] is GroupBox)<br />
{<br />
for (int x = 0; x < Controls[i].Controls[m].Controls.Count; x++)<br />
{<br />
if (Controls[i].Controls[m].Controls[x] is TextBox)<br />
Controls[i].Controls[m].Controls[x].Text = "";<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hello,
Again, I have to tell that this is bad programming!
Notonly that you are accessing again over multible indexer, in this case a recursive method would be the OOP solution.
Please think about that, bevor posting codesnippets like that.
All the best,
Martin
|
|
|
|
|
I prefer it this way:
foreach (Control c in Controls) {
TextBox tb = c as TextBox;
if (tb != null) tb.Text = "";
}
I seldom use "is" (only if you want to check the type but dont need to access any
members of the specialized object).
Luc Pattyn
|
|
|
|
|
Hey coders what's up?
Result required:
to be able to highlight a specific area of an image when a button is turned on.
when a button is turned off remove that highlighting.
Here is my problem:
I have a form that displays a map image inside a picture box control.
I created a graphics object out of the picture box such as *picturebox1.CreateGraphics()*
and then I use it to highlight specific areas of the map when a certain button is turned on
using a transparent brush such as
///////square to be highlighted//////////////
Point[] squareAPoints = new Point[4];
squareAPoints[0] = new Point(100,200);
squareAPoints[1] = new Point(200,200);
squareAPoints[2] = new Point(200,300);
squareAPoints[3] = new Point(100,300);
///////////////////////////////////////////
Graphics grfx = picturebox1.CreateGraphics();
Brush highlighterBrush = SolidBrush(Color.FromArgb(100, Color.Red)) //(setting the alpha to 100)
grfx.FillPolygon(highlighterBrush, squareAPoints)
now when I turn a certain button off I want this highlighting to be removed, how can I do so?
please help with ideas, tutorials, codes, lessons anything to achieve the end results will be appreciated.
|
|
|
|
|
well, you could just add a boolean, as in if button_pressed == false then draw the highlight, else don't.
|
|
|
|
|
oops well let's clear it up
my question was not regarding the button part
it was regarding the graphics part itself
how to remove the highlighting after I've drawn it using FillPolygon?
|
|
|
|
|
Hi
Simply call Picturebox1.Invalidate() and the hilight will be gone
|
|
|
|
|
when i write in visual studio i get dot and arrows instead of spaces how can i remove it
|
|
|
|
|
Edit > Advanced > View White Space
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
I need a DateTimePicker which in(de)crements the date, if the hours in(de)crement at 24h/0h.
I started with two DateTimePickers (date/time). The problem is that the scroling part of the timePicker fires no event, if one hits the scrollbar. So I can not see, if the user enters a new time or increments the time by scrolling.
Are there any solutions?
Thanks!
Ariadne
|
|
|
|
|
hi all,
I need to extract a part of the string using regular expression.Say for example, if we have a string like this,
<?xml version="1.0" encoding="UTF-8"?>,
I need to extract the version part alone.
Can anyone suggest me a regular expression to work out this?
Thanks in advance.
Regards
Anuradha
-- modified at 9:15 Tuesday 6th February, 2007
|
|
|
|
|
Your exemplary string is not displayed. Either replace any < character with < or check the "Ignore HTML tags in this message" option beneath the smilies.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hi all,
Sorry for the inconvienience.
I need to extract a part of the string using regular expression.Say for example, if we have a string like this,
<?xml version="1.0" encoding="UTF-8"?>,
I need to extract the version part alone.
Can anyone suggest me a regular expression to work out this?
Thanks in advance.
Regards
Anuradha
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
I am no regex expert but the following should match the version part : version="[0-9.]*"
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i am not sure abt the regular expression however take alook at this:-
ex: string s="asdfghjkl"
s.substring(3, 4);
-----this displays a part of the string which starts with the third position and the lenght of the string would be 4 from that position!!
Hope this helps!!!!
Gautham
|
|
|
|
|
Thanks for the reply.
But i am not sure of the length of the string which i am going to extract.In that case i cannot use a substring to extract the string.
Hope i am clear.
Thanks once again.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
Try:
string test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
string pattern = ".*(version=\".*?\").*";
string result = Regex.Match(test, pattern).Groups[1].Value;
This will match the version attribute with a result of: version="1.0"
I'm sure you will want to make this more generic.
Kathy.
|
|
|
|
|
Off the top of my head:
\<?xml version="(?<version>[0-9]\.[0-9])"
Remember to escape out anything needed for a string (e.g. the \ and " )
When you get your Match object back from the regular expression you'll find in the Groups collection an item keyed "version" . this will be the version number.
string version = myMatch.Groups["version"];
|
|
|
|
|
Try this:
version\=(?<Version>\"[0-9 \.]*\")
|
|
|
|