|
this is a really generic regex for a decimal value, ^\d*\.\d*$
I'm listening but I only speak GEEK.
|
|
|
|
|
I have a situation I am not sure how to deal with.
I have a class derived from the DataTable class
When I call the GetChanges form within an instance of the derived class the constructor of the derived class is called instead of just the DataTable constructor.
this.GetChanges();
I was expecting that only the Datatable constructor would be called. Is there a way around this ?
I tried calling
base.GeatChanges();
but same result.
|
|
|
|
|
It's called inheretance and Object-Oriented Programming.
only two letters away from being an asset
|
|
|
|
|
Since when is the method GetChanges a constructor for the DataTable class?? Or any class for that matter?
|
|
|
|
|
The GetChanges function has DataTable as a return type, so yes, at some point the constructor for the DataTable type will be called.
|
|
|
|
|
True, mostly. The constructor for A class will be called. How about base.GetChanges() .
|
|
|
|
|
|
I don't have a problem understanding inheritence
What I am not sure is why since the return type of the GetChanges is DataTable, I expect the DataTable contructor to be called but if I call that same function form a Class derived form DataTable all of a sudden the constructor of the dirived class is called although the return type is still a DataTable, I didn't touch that function. Here is the situation as clear as I can make it:
class myType : DataTable
{
myType():base()
{}
public someFunction()
{
code....
DataTable someDataTable = this.GetChanges();
}
In the last line a myType seems to be created by the Activator, I would have expected it to create a DataTable, nothing more.
|
|
|
|
|
Microsoft documentation says the GetChanges method:
Gets a copy of the DataTable containing all changes made to it since it was last loaded, or since AcceptChanges was called.
My guess is that it is using DataTable.Clone and the documentation on DataTable.Clone notes that "If these classes have been derived, the clone will also be of the same derived classes". See Documentation.[^]
So it is copying your instance (which is of MyType) and returning it as a DataTable. Overriding DataTable.Clone or GetChanges might fix your problem.
topcoderjax
|
|
|
|
|
Makes sense, thanks for the input
|
|
|
|
|
i would like to invite help of expert .net programmers/ .net architects for creating test questions for online testing platform.
compensation at $50 for 200 questions/answers . plus credits on test site for your effort.
http://jhatak.com/uwebcertify/index.aspx
i also require similar help for java question bank
your help appreciated
|
|
|
|
|
The job board would the place for this, not a programming forum
only two letters away from being an asset
|
|
|
|
|
I want to take the backup of mysql database through programming.
Any ideas? Any Links?
Thank you.
|
|
|
|
|
Create a stored precedure that does the backup and execute it from the code
|
|
|
|
|
hello,
i have to use a component to extract exif data from jpg and tif files in my application. everything works fine so far. the component returns apex values as strings (formatted as fractions), e.g. 5000/100 for ShutterspeedValue or 227/32 for FocalLength.
i've read in the EXIF spec that there are quite difficult formulas to be used to calculate the real values. since i'm not a math-genius i'd like to ask if someone has done this already and can point me to some c# snippets.
i'm pretty desperate on this one and appreceate any help. thanks in advance.
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
Hi,
How can I validate the NumericUpDown value while it is being entered and prevent input?
For example if the max = 10 and min = 0 I would like the input of
11 to remain 1.
At validation the value vould become 10.
Regards
TooDoo
|
|
|
|
|
Web or Windows? If web, you need to write some javascript to validate it as it is being changed. Windows, handle the lost focus event.
only two letters away from being an asset
|
|
|
|
|
Try this:
private void textBox1_KeyDown( object sender, KeyEventArgs e ) {
if ( e.Control ) {
switch ( e.KeyCode ) {
case Keys.X:
case Keys.C:
break;
default:
e.SuppressKeyPress = true;
break;
}
} else {
switch ( e.KeyCode ) {
case Keys.NumPad0:
case Keys.NumPad1:
case Keys.NumPad2:
case Keys.NumPad3:
case Keys.NumPad4:
case Keys.NumPad5:
case Keys.NumPad6:
case Keys.NumPad7:
case Keys.NumPad8:
case Keys.NumPad9:
case Keys.D0:
case Keys.D1:
case Keys.D2:
case Keys.D3:
case Keys.D4:
case Keys.D5:
case Keys.D6:
case Keys.D7:
case Keys.D8:
case Keys.D9:
case Keys.NumLock:
case Keys.Left:
case Keys.Right:
case Keys.Back:
case Keys.Delete:
break;
default:
e.SuppressKeyPress = true;
break;
}
}
}
private void textBox1_KeyPress( object sender, KeyPressEventArgs e ) {
Int16 num;
if ( Int16.TryParse( textBox1.Text.Trim() + e.KeyChar.ToString(), out num ) ) {
if ( !( num <= 10 && num >= 0 ) ) {
e.Handled = true;
// Handle the key press event and display nothing.
}
}
}
If it is a windows application.
I'm listening but I only speak GEEK.
|
|
|
|
|
Hi again,
If I enter a value greater than Max, I can by having keyUp event, get the NumericUpDown to validate efter each input but the value and text is reset to a valid value before I get to know what the nonvalid value actually was or even if the entered value was not valid.
Can I get the actual value before it is reset or get an indication that the value is reset?
Regards,
TooDoo
|
|
|
|
|
In the KeyPress Event the value would be e.KeyChar as a char datatype or e.KeyChar.ToString() for a string datatype.
I'm listening but I only speak GEEK.
|
|
|
|
|
Hi again,
by that I get the just entered char but and to check the total value I have the merge the already entered value and the just entered concidering position also.
But for a very short time before the value out of range is set to Max/Min you get to see the total value added. Can't I get it somehow?
Regards,
TooDoo
|
|
|
|
|
OK, then move the KeyPress code to the Validating Event and alter the following:
if ( Int16.TryParse( textBox1.Text.Trim() + e.KeyChar.ToString(), out num ) ) {
TO
if ( Int16.TryParse( textBox1.Text.Trim(), out num ) ) {
Make sure take the Textbox Property CausesValidation = true;
I'm listening but I only speak GEEK.
|
|
|
|
|
Dear All,
I want to add menuitems at run-time. If I use a menu, I can use the following method :
menuItemFile.MenuItems.Add(0, new System.Windows.Forms.MenuItem("-"));<br />
foreach (FileInfo XmlDescriptorFile in XmlDescriptorFiles)<br />
{<br />
try<br />
{<br />
blah blah ...
Is there a way to do exactly the same thing with a MenuStrip ?
Cheers,
|
|
|
|
|
DropDownItems.Add(...)
led mike
|
|
|
|
|
I can't for the life of me get this to work. My internet crawl has produced nothing.
Executing this code:
<br />
using (StreamReader sr = new StreamReader(f+"\\CDINDEX.txt"))<br />
{<br />
string line;<br />
<br />
while ((line = sr.ReadLine()) != null)<br />
{<br />
Console.WriteLine(line);<br />
}<br />
}<br />
I get the following exception: " The given path's format is not supported."
Using a messagebox the path clearly reads: "c:\test\CDINDEX.txt" which is the correct and true path to the file.
Can anyone help me as to why for some reason Microsoft decided today not to like me?
Thanks.
|
|
|
|