|
public bool IsInteger(string sender)
{
Regex regex = new Regex("[^0-9]");
return !regex.IsMatch(sender);
}
hi i get confused with the code above... why when i put e.g. 333 as the sender..
regex.IsMatch(sender); this is returning false ?? and i must put a ! there ??
my logic is .. when regex[^0-9] = integer then it must return true...
pls advice
|
|
|
|
|
public bool IsInteger(string sender)
{
return Regex.IsMatch(sender, @"^[\d]*$", RegexOptions.None);
}
How about this ? BTW, easy solution is int.TryParse() than this.
|
|
|
|
|
angels777 wrote: my logic is .. when regex[^0-9] = integer then it must return true...
Your code is wrong, the return value should not be 'notted'.
|
|
|
|
|
Maybe OT, but why are you not using bool int.TryParse(string,out int) ?
|
|
|
|
|
i want to update an image field of a record in SQL but i can not .
i must first delete the record and then insert it but i want to update the record.
please help
|
|
|
|
|
imannasr,
Google?[^]
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I have this large number of textboxes which is 16 textboxes across and 16 textboxes down, totaling 256 textboxes.
I have this software that generates the hex display all will be displayed at the same time. I noticed that there is the lag of time to populate each of them.
An engineer of mine thought about using Textboxes[] but I am not sure if its possible to "link" the textbox array with the cells that are on the GUI.
For example:
for the control that is on the screen is named tbCell_00 and next to it is tbCell_01
now for the textbox array, is it possible to do this for the two textboxes above:
TextBox[] tBoxes = new TextBox[2];
tBoxes[0] = tbCell_00;
tBoxes[1] = tbCell_01;
Anyone can help?
Thanks!
|
|
|
|
|
Yes, that will work fine ( did you try it ? )
A textbox is a class, so all you're doing is organising references to the existing controls, not creating deep copies.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
okaay. I did try that and it works. But I would have to do that 256 lines for each textboxes.
I'm not sure how to use for-next loop to Control TextBox's name "tbCell_00"
for example,
for (int i = 0; i < 2; i++)
tBoxex[i] = tbCell_00;
\-------/
this is the issue: ^
since that tbCell_00 is the Gui's textbox name. Is there a way to convert string into TextBox's name so I can use it as part of for_Next loop.
for example: "tbCell_" + i.ToString("X2") <---- Convert that to TextBox Name
|
|
|
|
|
You could use reflection to find textboxes that way. Why not just use a 2 dimensional array ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
why not try like this:
Control [] o = Controls.Find("textBox1", true);
the method Controls.Find() may be suitable for your situation.the first argument is your name of specific textbox control.
EG.
for (int i = 0; i; 2; i++)
tBoxex[i] = Controls.Find("tbCell_" + i.ToString("00"), true);
have fun!
|
|
|
|
|
I like that. So I tried this code:
TextBox[] tboxes;
for (int i = 0; i < 256; i++)
tboxes[i] = this.Controls.Find("tbCell_" + i.ToString("X2"), true);
and I got this error:
Cannot implicitly convert type 'System.Windows.Forms.Control[]' to 'System.Windows.Forms.TextBox'
|
|
|
|
|
because Controls.Find returns an array of Conrols hence the Control[] in the exception.
Dave
|
|
|
|
|
1. Call SuspendLayout() when creating the text boxes and ResumeLayout() after that (consult how VS generate the code in InitializeComponents()).
2. Enable double buffer on the forms.
3. Do you repopulate each and every textboxes every x seconds? Does the values change very frequently? Are you using DataBinding?
4. If the textboxes are only for display (no editing from user), you may want to consider different kind of control for displaying (DataGridView, ListView, owned drawn display, etc).
|
|
|
|
|
Item 1: No difference.
Item 2: Double Buffer? Not sure how to do that.
Item 3: No not every x seconds. I do re-populate after clicking on the button to obtain the hex dump from a memory chip.
Item 4: Could try for DataGridView.
|
|
|
|
|
Double Buffer can be found as Form property.
|
|
|
|
|
Why don't you use a DataGridView ? You have several predefined cell-types, textbox, combobox, checkbox,...
|
|
|
|
|
I have a custom control which produces a fairly intricate graph that takes some time to initally draw. The user uses the mouse to draw a selection rectangle on part of the image to be zoomed in on. This part of the code works fine, but the drawing is sluggish.
Right now, as the user clicks and drags, the graph is drawn and the rectangle is then drawn over that, so each time the user moves, the image must be redrawn. I know part of the paint message is the region that was invalidated, but its too complicated to redraw just a portion.
Is it possible to store the control image as a bitmap after drawing the first time, then whenever the mouse moves, replace the image with the bitmap stored in memory and draw my new selection rectangle? Is this a good approach, and if so, how do I get and set the control image? If this isn't a good approach, what is a better one?
Thanks,
Aaron
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Yes, just draw the graph to the bitmap in the first place, and draw that in your paint event.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That was very simple to get working, changes for the reassurance
modified 12-Jul-20 21:01pm.
|
|
|
|
|
hi
i have a method that return DataTable (named GetData), now i want to load returned DataTable object to DataSet by this code :
this.ds.Load(dal.GetData(cmd1).CreateDataReader(), LoadOption.OverwriteChanges, new string[] { "transaction1" });
but before, load data, i want to clear some tables of my dataset objects by this code :
this.ds.Tables[0].Clear();
but at runTime the following error has shown me :
Cannot find table 0
how to solve my problem and how to clear before fill ?
thanks
|
|
|
|
|
hdv212,
if (this.ds.Tables.Count != 0)
{
this.ds.Tables[0].Clear();
}
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
First check your dataset have any table. If not no need to clear.
kesavan
|
|
|
|
|
Hello All,
I have this one asp.net 2.0 project that throws the following error when I attempt to use System.Diagnostics.Debug.WriteLine
{"Couldn't create listener 'textWriterTraceListener'."} System.Exception {System.Configuration.ConfigurationErrorsException}
It has an interesting inner exception of:
InnerException {"Illegal characters in path."} System.Exception {System.ArgumentException}
All of the other asp.net 2.0 apps I have run perfectly fine with that statement and previous versions of this application ran fine. Any ideas?
Thanks in advance,
Ryan
|
|
|
|
|
RB@Emphasys,
Show us some code.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|