|
|
my company have server to login, and can chat local with MSN
I want that how to connect to it with my program, someome can give me some idea to solve it
thanks
Nho'c ti`
|
|
|
|
|
Hello, I am a newbie at C#. I am trying to make a text box only allow alpha characters, such as a - z upper and lower case, the backspace, and space keys. How would i write that in the keypress event and how do i get it to activate on that text box? thanks any help will be appreciated.
|
|
|
|
|
Something like this should get you started:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (Char.IsLetter(e.KeyChar) || Char.IsPunctuation(e.KeyChar)
|| Char.IsSeparator(e.KeyChar) || Char.GetNumericValue(e.KeyChar) == -1)
e.Handled = false;
else
e.Handled = true;
}
-Nick Parker
|
|
|
|
|
well thanks for the help anyways but it doesn't work. i can still type numbers and wierd characters into the text box. Does anyone else have any ideals?here is what my teacher showed us in class but i can't get anything out of it? thanks
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar < 'a'||e.KeyChar > 'z')&& e.KeyChar != '\b')
e.Handled = true;
}
|
|
|
|
|
kharr1027 wrote:
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar < 'a'||e.KeyChar > 'z')&& e.KeyChar != '\b')
e.Handled = true;
}
A few things, first of all I just re-tried the code example I gave you and it does work, however I noticed in the code example you listed you have Form1_KeyPress which appears that you have an event handler registered for the KeyPress event of a Form , not a TextBox . Make sure whatever the name of your textbox that you add to your form includes the following event/delegate assignment (for this example the name of my textbox is simply the default of textBox1 ):
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
then the following will work to only allow alphabetic characters, space and backspace entries:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (Char.IsLetter(e.KeyChar) || Char.IsPunctuation(e.KeyChar)
|| Char.IsSeparator(e.KeyChar) || Char.GetNumericValue(e.KeyChar) == -1)
e.Handled = false;
else
e.Handled = true;
}
-Nick Parker
|
|
|
|
|
Character codes. Look them up and compare them. Filter out what you dont want.
You set e.Handled to true when you dont want the character entered. Other wise
if it is valid e.Handled = false;
|
|
|
|
|
Dear all,
I've got a problem on controlling Numermic UpDownControl. In my application, I have 6 UpDownControl, they are L, R, Top, Bottom, width and height. now I would like to check the input of L value is over range or not.
the default maxValue of L is set to 200, and it is various of "width", that's means, if L or R decrease, width will be decreased. The equation is
DWidth = L + R + "Width"
The following code, I check if the "width" value is met its minimum value, then L, R, can't be increased.
<br />
private void LUpDown_ValueChanged(object sender, System.EventArgs e)<br />
{<br />
if(OwnChanged)<br />
return; <br />
<br />
if(!AngleChange && !changeValueOnly)<br />
{<br />
if(Angle == 0)<br />
{<br />
decimal range =DWidth- LUpDown.Value - RUpDown.Value;<br />
<br />
if(range < SizeWUpDown.Minimum)
{ <br />
OwnChanged=true;<br />
LUpDown.Value = DWidth - SizeWUpDown.Minimum - RUpDown.Value; <br />
OwnChanged=false;<br />
}<br />
changeValueOnly = true;<br />
SizeWUpDown.Value = DWidth- LUpDown.Value - RUpDown.Value; changeValueOnly = false;<br />
}<br />
else<br />
{ ..... }
if the value is over its minVaule, I will set back the value of L like "equ1", then it will activate its valueChanged event again, so I use OwnChanged to prevent it. The problem is I don't know why the "problem?" line can't execute, and this function will be return once it reach this line..
I just know, If I cross out LUpDown.Value in "problem?" line,like
SizeWUpDown.Value = DWidth - RUpDown.Value; //<---problem?
the program can pass this instruction.
Am I do it in wrong way? How can I solve it?
Please Help... Thanks
|
|
|
|
|
Is there a way to create a managed array from a pointer to a block of unmanaged memory? I need to allocate a bunch of memory outside of the garbage collector, but I also need to access it through a managed byte array. Is this even possible? Right now, I'm creating the managed array and using a pointer to the first element, but this has a random habit of breaking when the garbage collector decides to move the managed memory around .
Updating the pointer to the new location isn't really an option, as the pointer is being passed to an unmanaged DLL (which blows up when the GC moves the memory ).
Josh
Find a penny, pick it up, and all day long you'll have a back-ache...
|
|
|
|
|
Try this[^] and this[^].
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Thanks for the links. I'd already read the article on pointers, but missed the article on arrays. Unfortunately, I didn't see anything in the array article that would help me create a managed array reference to an unmanaged memory block. I'll just have to think harder, I guess.
Josh
Find a penny, pick it up, and all day long you'll have a back-ache...
|
|
|
|
|
Hi,
I have a datagrid which I filled with a dataset. I set the datagrid to read-only..
I wish to delete the selected row of the datagrid. The only problem is how I determine which row is selected in order to deleted from the database???
I have already tried using the currentcell property of the datagrid and getting the row number to determine which row in the data table was selected.. the only problem with that is if I rearrange the elements of the datagrid (order alphabetically) then the currentcel row number does not much to the corresponding row in the database, thus I end up deleting the wrong row??
How can I get the correct selected row and match it up with the row in the actual database??
I greatly appreciate all help!!
|
|
|
|
|
mdolby wrote:
the only problem with that is if I rearrange the elements of the datagrid (order alphabetically) then the currentcel row number does not much to the corresponding row in the database, thus I end up deleting the wrong row??
I don't think this is true. It sort DataSet too so it will delete correct row. how do you delete it.But what ever you do you can perform it like this:
Your table must have a KeyField, when you select a row for delete get value of it and delete from databse by using that field.
Mazy
No sig. available now.
|
|
|
|
|
Hi,
i am just learning web services with .net and have created a small one, then deployed it so it is a .dll file.
can somebody point me in the right dirrection for connecting my web page to use this service
thanks
col
|
|
|
|
|
chekc out the articles here but basically create a wsdl file. use the disco and wsdl utilities with .net or click on the project name in the solutions explorer and click add web reference then naviaget to the wsdl file you created
I would read a tutorial article on here first though
|
|
|
|
|
Hi, All:
I'm writing a Windows Form client that utilizing DIME to invoke a web service layer on the server that in turn exposes Visual SourceSafe's COM interface.
The ObjectDisposedException occurred whenever I try to invoke more than one web method after I open the SourceSafe's database. I always receive "Can not access a closed file". The above mentioned exception is occurred in mscorlib.dll. Does any one knows how to find out about the file that causes this exception? Any advise will be greately appreciated.
Harry
|
|
|
|
|
Hi,
I need help in asp.net C# programming.
I have a requirement to add a picture and data table to Excel sheet programmatically from a C# asp.net application.
I am using Windows 2000 Server with Office XP installed.
Additionally I also installed Office XP PIA's (available as download in Microsoft site).
I have added Microsoft Excel 10.0 Object Library & Microsoft Office XP Web Components (COM) references to the project.
There is no probelm exporting data to the xlsheet.
I have a probem when I add picture to the xlsheet.
Following is the code, I am trying to execute.
using Excel = Microsoft.Office.Interop.Excel;
using OWC10;
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
Excel.Worksheet xlsheet1 = new Excel.WorksheetClass();
OWC10.ChartSpace objChartSpace = new OWC10.ChartSpaceClass();
addPictureToExcelSheet(objChartSpace,xlsheet1);
xlsheet1.SaveAs(Server.MapPath(".")+"\\"+"test.xls","XLS","","",true,false,false,"","",true);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsheet1);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objChartSpace);
xlsheet1=null;
}
catch (System.Exception e1)
{
Response.Write(e1.Message);
}
}
private void addPictureToExcelSheet(OWC10.ChartSpace objChartSpace,Excel.Worksheet objSheet )
{
try
{
string strPicFileName;
Excel.Shape objPicture;
int sizeX = 800;
int sizeY = 600;
strPicFileName = Server.MapPath(".") + "\\flag_uk.gif";
objChartSpace.ExportPicture(strPicFileName, "gif", sizeX, sizeY);
objPicture = objSheet.Shapes.AddPicture(strPicFileName, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0, sizeX, sizeY);
}
catch (System.Exception e)
{
Response.Write (e.Message);
}
}
I have also made my application to run as a single threaded application. (using ASPCompat = "true").
I get Exceptions & error messages.
Could anyone provide a better solution to my problem. OR tell me if I am missing something here.
Thanks in advance,
Vidya
Vidyar
|
|
|
|
|
I want to control the number of instances of my application and if this number is greater than a fixed number, give the focus to one of the opened instances.
Any suggestion??
Iván Fernández
|
|
|
|
|
|
hi, I am using following code to invoke my DLL and it's functions.
Assembly assemScenarioPreview = Assembly.LoadFrom(Some Path);
Type typeScenarioPreview = assemScenarioPreview.GetType(...);
Object obj = Activator.CreateInstance(typeScenarioPreview);
MethodInfo methodofScenarioPreview = typeScenarioPreview.GetMethod("Run");
methodofScenarioPreview.Invoke(obj, null);
methodofScenarioPreview = typeScenarioPreview.GetMethod("CleanUp");
methodofScenarioPreview.Invoke(obj, null);
In first chance it's get executed. but next time it throws an Exception.
"Exception has been thrown by the target of an invocation"
If I closed the client then then again ran the same code. it works..
What is the possible problem ..
|
|
|
|
|
Generally, a try/catch block around this will let you see what the exeption says about itself. Very useful stuff. Do something like the following, and you'll get information about the exception. (Also, be aware that the InnerException memeber may need to be looked at in some rarer occasions.)
try
{
// Your code here.
}
catch (Exception err)
{
System.Diagnostics.Trace.WriteLine(err.ToString());
// or
MessageBox.Show(err.ToString());
}
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
Please help me if you know the answer to this. I want to create a dataAdapter, that fills a dataSet. However, I have a stored procedure that I want to use, that takes one int as input. I have been trying this for a few hours now, and have come no closer.
|
|
|
|
|
Design time:
You have to set your parameter to the Parameters collection of the Command object.
Run time:
Use the Add method of the Parameters collection to create a Parameter object for the parameter in the stored procedure.
SqlCommand[^]
"If a jug falls upon a stone, woe to the jug. If a stone falls upon a jug, woe to the jug. Always woe to the jug"." - KaЯl This signature was created by "Code Project Quoter".
|
|
|
|
|
Firstly, what is the best way to delete some text. What I want is the number "563.5423" to become "563.54".
|
|
|
|
|
See Remove or Substring or Replace methods of string object
Hi,
AW
|
|
|
|