|
Hello
I wanted to use a masked text box for some trivial need in data entry :
Limit to some allowe char
Example :
"YN<space>"
or
"X"
or
"AKLV"
But such trivial thing doen't seems to be possible with maskedtexbox or at least not good documented !
Does anyone have an idea how to do this with csharp
Obviously I can probably manage keyboard event to do this.
But in such case I will write my own maskedtextbox to replace this poor one !
|
|
|
|
|
Handle the Text-Changed event, and just check the string that's in the box.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank a lot John
I will do so
But I realize now that the use of masked text box is very limited
I don't even need a masked text box to do that !
I can't believe that they don't even think for such need
Use a regular expression in the mask for example !
|
|
|
|
|
Given your examples, I'd say it would be impossible to build a mask for that. The best you could do is to force all-uppercase alphabetic characters, but you'd still have to control which characters and how many in your code.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello John
I don't agree with you
It is impossible with the sad actual masked text box
But it would be very easy in the concept of such control to provide those feature
At least allow regular expression !
20 years ago using DOS interrupt I made a full masked screen editor much more powerfull that this poor maskedtextbox
|
|
|
|
|
The masked textbox sucks. Handle the key pressed event in the normal textbox, then reject keypresses you don't want from there.
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 )
|
|
|
|
|
He's not going to listen to you. He built a DOS-based masked edit thing that's much better than the one in .Net (his claim, not mine). The absurdity is that if he's got the skillz, why the hell is he in here asking how to do it?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi
I am working on a project in which I need to NUnit testing. To do that I need to write tests for each class. I am trying to automate that process.
1. How to know names of public properties of class in .Net dynamically?
2. I am also looking for property types to set some default values.
3. There might be nested classes also. I am wondering how to traverse that nested tree?
Please advice. Thanks
Pankaj
|
|
|
|
|
|
I'm sure if you look around you'll find something that already exists to do this kind of job.
|
|
|
|
|
Using LINQ because it's so much easier...
1) How to know names of public properties of classes in .NET dynamically?
var properties = yourType.GetProperties().Select(p => p.Name); 2) Property types
var properties = yourType.GetProperties().Select(p => p.PropertyType);
var instance = Activator.CreateInstance(properties.First()); 3) Nested classes
var childClasses = typeof(Program).GetNestedTypes().Select(t => t.Name);
Note you can retrieve these without LINQ just forget the .Select(...) pattern, but you asked for names which implies strings so I used LINQ to extract the names rather than a loop.
|
|
|
|
|
Hi Everyone,
I'm running into a major problem with the combobox created by bestcomy. I also posted a comment on that article but its also very urgent so I thought I would try here as well. I recently had to re-install VS studio 2002 on my laptop and the code that I had to run the combobox created by bestcomy is no longer working. I'm getting this error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Method LoadPostData in type Bestcomy.Web.UI.WebControls.ComboBox from assembly LoadPostData does not have an implementation.
Source Error:
Line 187: <td class="heading" width=135px>Central Office:</td>
Line 188: <td width=220px>
Line 189: <bestcomy:ComboBox id="ddlCO" runat="server" Width="120px" AutoPostBack="true" ></bestcomy:ComboBox>
Line 190: </td>
Line 191: <td>
Has anyone seen anything like this before? Any help would be greatly appreciated. thanks!
|
|
|
|
|
ceetee,
Wrong forum. You need ASP.NET.
Regards,
Gareth.
|
|
|
|
|
|
Ive searched the web and it seems that blocking Ctrl+Alt+Del is almost impossible in Windows XP. Is there a way to keep your program constantly looking to see if taskman.exe or the taskmanager from opening? like it kills the task when the program detects that it is running? Im making a program to lock my computer for my own use and figureing this out would really help. So im looking for a way to get it to loop and look at the running tasks all the time and wait for it to open. Any advice? im new at C# so take it easy please! =)
Y*Live Long And Prosper*Y
|
|
|
|
|
That key sequence can only be trapped by kernel-mode code. It's what's called a secure attention sequence. Your best bet probably is to hide your process (which I don't remember how to do). Either way its probably not a good idea to tamper with the Task Manager operation.
|
|
|
|
|
The only way to stop TaskManager from showing up is to block it using Group Policy. You can't stop it from launching from your code. The absolute best you can do in code is to find the TaskManager process in the process list (see Process class documentation) and terminate the process after it shows up. That means the user will see the TaskManager launch, then quit.
|
|
|
|
|
|
Doing that would be user hostile. Would you want your Task Manager to be disabled? I know I wouldn't.
|
|
|
|
|
I need to write a manager program connect to a remote server to display the status of the server. I have a login form, when i connect successful it will show the main form.
Currently I still don't use the login Form, and now I want to add it to the program rather than using it by default. Below is the code of the Program.cs. How can I add a form ( in this form I have 4 text box for host/port/loginame/pwd and two button Connect and Exit) to the main Form but still do not change the overall structure of the program?
Here is the program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace MainForm
{
static class Program
{
const string host = "10.0.0.2";
const int port = 5000;
const string loginame = "name";
const string loginpwd = "pwd";
.....
public static AManager manager;
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
checkManagerAPI();
Application.Run(new FrmMain());
}
// checkManagerAPI() region is here:
#region checkManagerAPI()
checkManagerAPI();
{
manager = new AsteriskManager(host, port, loginame, loginpwd);
try
{
manager.Login(); // Login only (fast)
}
catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadLine();
manager.Logoff();
return;
}
// a lot of code here
}
#end region
}
}
I still don't know how to write the Connect button event clicked: private void btnServerConnect_Click(object sender, EventArgs e). Maybe I still have some difficulties in understanding the structure of the login, the relation with the login form, main form and the file program.cs. How to organize it in an appropriately manner?
Please help me!
Thank you very much!
|
|
|
|
|
**DISCLAIMER** This may or may not be the best way to accomplish this task. This code is based on this article.[^]
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginApplicationContext loctx = new LoginApplicationContext(new Form1(), new LogIn());
Application.Run(loctx);
}
}
public class LoginApplicationContext : ApplicationContext {
private Form appForm;
public LoginApplicationContext(Form app, Form login)
: base(login) {
appForm = app;
}
protected override void OnMainFormClosed(object sender, EventArgs e) {
if (sender is LogIn) {
if ((sender as LogIn).DialogResult == DialogResult.OK) {
base.MainForm = this.appForm;
base.MainForm.Show();
} else {
Application.Exit();
}
} else if (sender is Form1) {
base.OnMainFormClosed(sender, e);
}
}
}
In your login form you'll have to change the Form's DialogResult before you exit. I tested this and it seems to work, though again I don't know it it's the best approach.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi,
I have two xml files I added it in to the Property.resource as a embedded resources. how I know that which property is associated which file at run time. means I want file name of respective resource property.
thanx in advance....
|
|
|
|
|
Hi there,
First of all let me say that I tried to find this here in codeproject and google... but I think I'm missing the keywords to find what I want.
What I'm looking for I think it is pretty common.
The thing is... after learning about delegates and threads and trying to implement it in my project I'm still having a freez while the client draws grids.
Let's go to the details:
I have a mainprogram that calls diferent forms from its menu.
One of this forms needs to draw graphics and (Xceed) Grids with lot of data.
The problem: while drawing these graphics and grids, the whole program freezes (all open forms, this form and the mainprogram).
While trying to solve this problem I started researching about delegates, threads and everything else that popped up in the articles. With all I learned I was able to do some things in my project that increased its performance. But in this particular problem, even when the "drawing function" is put in another thread, the mainprogram continues to freez.
I really want to understand why this is happening and how to solve this, so please tell me if I'm wrong.
I'm guessing that the problem happens because the "drawing function" needs to be runned in the same thread as the "form creator" thread, in this case the mainprogram. This way, although the "drawing function" is called through a delegate, its begin starts with "if (this.invokeRequired) this.Invoke" to avoid cross threading problem.
I don't really know in wich thread the "this.Invoke" will execute my "drawing function" but I'm almost certain that is in the mainprogram's one. So it will keep on freezing.
With this in mind I looked in google and here at codeproject the only way I though of to solve this: a way to run the Form in a diferent thread from the mainprogram. Just like as it was a diferent process. This way the "this.Invoke" would call the paralel thread that runs only the Form, and not the whole mainprogram, stopping the freez problem.
I didn't find something that made me do this succesfully and that brings me here.
Can anyone teach me a way to work around this problem? If there is a way to solve this without creating a thread for this form alone, please, I would like to hear it (if creating a thread is a solution at all... I really don't know).
If I said something wrong, I'm sorry, I'm still a jr here. Please tell me so I can learn better about this.
Thanks in advance,
Oscar
|
|
|
|
|
What exactly is taking time? The drawing of data or the loading of data to memory?
I'd be surprised if it's the former - datagrids are usually built to show large amounts of data without freezing.
And yes, you're right, Invoke will execute the delegate passed to it on the UI thread. Can you paste the code (or atleast pseudocode) which you think is taking a long time to complete?
|
|
|
|
|
Hi there Senthil,
First of all thanks for the answer.
What is taking time is the drawing of the data. In our project we use a component called Xceed Grids for better visualization of the data. I dunno if it is quick or if it is slow.
All the data come from a XML that my project receive, all the processing of the document don't take much... the problem is exacly in the function that draws all the grids and the grafics.
The code that takes long is a part of the Xceed Component where we creat the grids.
For instance:
<br />
Agrid.BeginInit();<br />
Agrid.Clear();<br />
<br />
Agrid.SynchronizeDetailGrids = true;<br />
ColumnManagerRow cmrNovo = new ColumnManagerRow();<br />
Agrid.FixedHeaderRows.Add(cmrNovo);<br />
((ColumnManagerRow)Agrid.FixedHeaderRows[0]).AllowColumnReorder = true;<br />
<br />
Agrid.Columns.Add(new DataBoundColumn("Groups"));<br />
Agrid.Columns["Groups"].Fixed = true;<br />
And many more Agrid.Columns.Add
After that We add detailGrids and we must for each column padronize a style.
The foreachs dont take long... almost nothing... the problem is when we run the
"Agrid.Endinit()".
That's the Xceed Grid method that actually draws everything.
If it was only one grid, everything was ok... but we have many grids like that one above to be drawed in sequence and shown in diferent tabs.
Well, did this give some more information?
Thanks in advance!
|
|
|
|