|
Do you have a programming question ? This doesn't look like one to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
need help with a regex that would split a given fullname to its corresponding
first name, last name, middle initial
im trying to emulate outlook's way of breaking down the full name to its corresponding
fields.
any regex or class to do this? help is highly appreciated.
Life - Dreams = Job
TheCardinal
BenPOS Systems
|
|
|
|
|
If you have name as "FirstName MiddleName LastName", just split it over space. Not sure how will you manage in case first name itself contains space.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
thanks, that's what i did but the one you've pointed out thats where my
problems begin
i just really need a regex or something to really isolate what i want to
be extracted and it would not matter if the user enters some of this format's.
lastname, firstname mi.
firstname 2ndname mi. lastname
i really wanted to have a result just like how outlook used a single
textbox for fullname, and breaks it down to its specific fields.
i dont like to implement IF's and Switch's, i think there a better solution
in splitting or extracting the fields
Life - Dreams = Job
TheCardinal
BenPOS Systems
|
|
|
|
|
I think a regex is going to be horribly complex, and even then won't work everywhere:
France: M. Pierre De Gaul
US: Dr M Jones
Japan: Surname first?
Ireland: Shaemus O'Connor
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Even that will not help. If first name can have a space, why can't middle name have one? Or even the last name?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
so whats the best way then?
maybe i will just use 3 textbox separating the 3 fields
and labeling then with the proper labels
hopefully there could be a better solutions for this.
Life - Dreams = Job
TheCardinal
BenPOS Systems
|
|
|
|
|
i have made a line and i update its end points in a loop ...basically to make a circle ... now what a wants is that when a line is made the previously created line should be deleted ?
need help plzz ?
i have tried dipose ??
|
|
|
|
|
previously created line must be draw again using background color.
|
|
|
|
|
First of all, wrong forum... but never the less
How are you trying to draw?
The right way to do it is firstly create a DoubleBufferedPannel . To do that create a new cs file in your solution and add the following code in there.
namespace DoubleBufferPanelNameSpace
{
public class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw,
true);
this.UpdateStyles();
}
}
}
compile your project and the you'll see the DoubleBufferPanel in your toolbox. Drop that on the form you want to draw on.
Then to do your GDI code all you have to do is use the panels paint handler like so
private void doubleBufferPanel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Brushes.Black), 0, 0, 10, 10);
}
If you want the image to be redrawn cause some of the variables that affect the drawing has changed you can call doubleBufferPanel1.Invalidate(); which forces the control to be redrawn.
Using this aproach there is no need to worry about disposing graphics objects as its done for you.
Hope this helps
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
hEY THANKS
I really cant understand why u made a new class ? i directly pasted a PANEL on the forum .
My main issue was not disposing ... my main issue was to erase previously created graphics .. ?
|
|
|
|
|
Two reasons. Every time a control needs to be redrawn by the OS it's OnPain't gets called. Creating your own class derrived from the control in question (Panel) gives you access to this method so you can guarantee your code is going to get called every time it is needed.
Doing it this way, you get a Graphics object for free. No need to use more resources and no need to remember to dispose of it.
A proposal for a slight improvement to Harvey's code:
public class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
this.SetStyle(
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw, true);
this.UpdateStyles();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
using (Pen pen = new Pen(Color.Black))
{
e.Graphics.DrawLine(pen, 0, 0, 10, 10);
}
}
}
|
|
|
|
|
If your drawing changes it will flicker and that's no fun... The extra class basically enables double buffering on the panel control and that eliminates the flickering.
Lets have a look at your OnPaint event handler code and see what we can come up with. And how would you like to erase these previously created graphics? What exactly are you trying to write?
The more info you give the better we can understand your problem
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
hi...
am developing an c# windows application in which i need to control the form controls from another form, i tried it but its not, so any one plz help me out in solving this..
thnks n rgrds
ageesh
|
|
|
|
|
You can do this by creating your own events.
Have a look at my article Delegates, Events, Event Arguments, and How They Fit Together[^]
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Hi,
Can you please tell me if there is a way to find if a file is already open or not?
|
|
|
|
|
We can use some tricky code fot this.
Open the file in Write mode so that you'll get an exception.Catch that exception.
If any good method is there let me know.
|
|
|
|
|
Actually i am getting the exception but i am not able to handle it..so in order to handle it i want to check if the file is already open or not
|
|
|
|
|
Can u post your code snippet so that we can help you.
|
|
|
|
|
Swetha Srinivasan wrote: i want to check if the file is already open or not
Do you know which process opened the file?
Have u got error when you open the file first time from your code?
Have u handled the stream properly?
I think its opened by CLR itself.isn't it?
|
|
|
|
|
I have solved the problem.I put the code in Try..Catch...
|
|
|
|
|
Hi All,
If I have a form with several buttons and the click event handler for all the buttons points to the same handler, how can I determine in handler which button was clicked?
this.button1.Click += new System.EventHandler(this.button_ClickHandler);
this.button2.Click += new System.EventHandler(this.button_ClickHandler);
this.button3.Click += new System.EventHandler(this.button_ClickHandler);
private void button_ClickHandler(object sender, EventArgs e)
{
MessageBox.Show("Who raised this event?");
}
|
|
|
|
|
you have object sender.
|
|
|
|
|
OF COURSE...I'm only annoyed because I didn't figure that out for myself. -Thanks
MessageBox.Show(((Button)sender).Name + " Who raised this event?");
|
|
|
|
|
A better way to do this is:
Button b = sender as Button;
if (b != null)
{
MessageBox.Show(b.Name + " Who raised this event?");
} Just casting the sender to a Button is a bad practice as it will throw an exception if the sender is not a button.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|