|
Why are you using Assembly.LoadFrom ? You can add control dynamically like this:
YourUserControlClass userCtrl = new YourUserControlClass();
userCtrl.myEvent += new EventHandler(this.myHandler);
this.Controls.Add(userCtrl);
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
By dynamically I mean totally dynamically. Like they browse and select a dll. So its not included in the solution before runtime.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
In that case, EventInfo class will help you. See this[^] link.
Or this[^] one.
Hope it helps.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
i need to validate the Textboxes that are created at runtime. The text should not be blank and it should allow only numbers.
|
|
|
|
|
Use a MaskedTextBox[^] instead.
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
|
|
|
|
|
maybe validate against a regex? ^\d+$
you could put it in the TextChange event handler method
eks.
private void textBox1_TextChanged(object sender, EventArgs e)
{
Regex r=new Regex(@"^\d+$");
Match m=r.Match(textBox1.text);
if(!m.Success) MessageBox.Show("Wrong input format");
}
or you could check the content of the textbox when it is submited, in the same fasion, using Regex and Match classes.
one idea is to make a class that inherits from the TextBox class, add a string attribute that can hold the regex expression, and use that class instead of the TextBox and store the regex in that variable, then you could just loop through all the controls when the user subits the data, an check it against the regex stored in that control, like this:
public class ExtTextBox:TextBox
{
public string ValidationRegEx;
}
....
ExtTextBox newETB=new ExtTextBox();
...
...
newETB.ValidationRegex=@"^\d+$";
...
this.Controls.add(newETB);
foreach(Control c in this.Controls)
{
if(c is ExtTextBox)
{
ExtTextBox tmpC=(ExtTextBox)c;
Regex r=new Regex(tmpC.ValidationRegex);
Match m=r.Match(tmpc.Text);
if(!m.Success)
{
}
}
}
modified on Wednesday, August 19, 2009 5:00 AM
|
|
|
|
|
Dear All:
Am trying to learn how to secure web application does any body knows resources that are really helpfull?? I read an article her in CodeProject that talks about basePages and how they inherit each other to authenticate what is good is that i already work with this methodology but i did not know that this way was a really good one, but as you all know we developers can't get enough so any one could help?????
Thanks
|
|
|
|
|
khalil.kamel wrote: Am trying to learn how to secure web application
IMO, this is subjective. Here[^] is a MSDN technet article which talks about some general techniques. You may be interested in this[^] wiki as well.
|
|
|
|
|
Ok thanks but am searching for this kind of article please check it it is really niceCodeProject Article
these kind of articles that would make a developer better that others and this is what am searching for
|
|
|
|
|
hi all,
i have a datagridview, i want to check cell value in CellEndEdit event. if the cell is empty, don't allow to leave it.
how can i do it?
|
|
|
|
|
set property
CauseValidation = true;
in CellValidating() event handler
dtGrdView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
here e will provide you the data entered in the data grid view
if (e.ColumnIndex > 0)
{
e.Cancel = true;
}
}
thats it!!
reg,
Deep
Happy Coding
modified on Wednesday, August 19, 2009 5:24 AM
|
|
|
|
|
thanks for Your answer, but
(i want check blank cells, when it's edit && now leaved)
when i check blank cell into if statement (for example if(datagrid[x,y].value.ToString()=="")) the cell value is the previous value
and it is True, only the cell is already empty.
What is the solution?
|
|
|
|
|
HI all,
i m using SmsSendMessage api for sending sms , its working fine .
i have one problem its still working when mobile have no sufficient balance for sending sms,in that case i want when mobile have no sufficient balance for sending sms than it display a message for balance enquiry and stop the message sending process.
please tell me how can i check the balance of mobile phone with codeing.
if possible please explain me with any example.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
This question has nothing to do with any sort of standard API offered by Microsoft in the .NET framework. So, you need to look at the library you are using, and see if it offers the functionality you need.
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.
|
|
|
|
|
|
Oh. you're using the compact framework. Why didn't you say so ? What have you done to try to find APIs that check if a phone still has credits ? I would be surprised if such a thing existed.
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.
|
|
|
|
|
actully i m inserting this exe in Windows based mobile and send sms tru this exe.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi,
I'm trying to connect with telnet to a switch a by typing it's user and password to be able to connect to it.
i found this code:
at - Here
i think the return message that i recieve it to long for the byte[].
The application fall he:
numBytesRead = ns.Read(readBuffer, 0, readBuffer.Length);
but i don't reciere any error message.
Can some please help me here ???
modified on Wednesday, August 19, 2009 7:36 AM
|
|
|
|
|
Is there any option to check how many bytes are waiting?
It's supposed to be some property of the NetworkStream?
|
|
|
|
|
Dear All,
I need to develop a program that gets signals continuously and then play them. So I play audio streams in 100ms periods. My problem is that there is an undesired sound in the onset and offset of each stream. For example I write a program which plays an audio stream with constant values as follow, but it makes a noisy sound instead of constant sound.
What's the problem? and what's the solution?
using System;
using System.Windows.Forms;
using Microsoft.DirectX.DirectSound;
using System.IO;
namespace TestSound
{
class CSound : Form
{
const int HEADER_SIZE = 44;
const bool FLAG_STEREO = true;
const short BITS_PER_SAMPLE = 16;
const int SAMPLE_RATE = 44100;
int numberOfSamples;
MemoryStream stream;
BinaryWriter writer;
Device ApplicationDevice = null;
SecondaryBuffer buffer = null;
BufferDescription description;
public CSound()
{
try
{
ApplicationDevice = new Device();
}
catch
{
MessageBox.Show("Unable to create sound device.");
ApplicationDevice = null;
return;
}
ApplicationDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);
description = new BufferDescription();
description.ControlEffects = false;
stream = new MemoryStream();
writer = new BinaryWriter(stream);
}
private void AddHeader()
{
stream.Position = 0;
writer.Write(0x46464952);
writer.Write((int)(HEADER_SIZE + (numberOfSamples * BITS_PER_SAMPLE * (FLAG_STEREO ? 2 : 1) / 8)) - 8);
writer.Write(0x45564157);
writer.Write(0x20746d66);
writer.Write(16);
writer.Write((short)1);
writer.Write((short)(FLAG_STEREO ? 2 : 1));
writer.Write(SAMPLE_RATE);
writer.Write(SAMPLE_RATE * (FLAG_STEREO ? 2 : 1) * BITS_PER_SAMPLE / 8);
writer.Write((short)((FLAG_STEREO ? 2 : 1) * BITS_PER_SAMPLE / 8));
writer.Write(BITS_PER_SAMPLE);
writer.Write(0x61746164);
writer.Write((int)(numberOfSamples * BITS_PER_SAMPLE * (FLAG_STEREO ? 2 : 1) / 8));
}
public void Play(short[] samples)
{
if (ApplicationDevice == null)
return;
stream.Position = HEADER_SIZE;
numberOfSamples = samples.Length;
for (int i = 0; i < numberOfSamples; i++)
{
writer.Write(samples[i]);
if (FLAG_STEREO)
writer.Write(samples[i]);
}
AddHeader();
stream.Position = 0;
try
{
if (buffer != null)
{
buffer.Dispose();
buffer = null;
}
buffer = new SecondaryBuffer(stream, description, ApplicationDevice);
buffer.Play(0, BufferPlayFlags.Default);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
static short[] samples = new short[4410];
static CSound sound;
static void Main()
{
Form form = new Form();
form.Show();
sound = new CSound();
Random random = new Random();
for (int i = 0; i < samples.Length; i++)
samples[i] = 1000;
while (true)
{
sound.Play(samples);
System.Threading.Thread.Sleep(100);
}
}
}
}
|
|
|
|
|
Hi Everybody
With Graphics Class in C# for example I draw a line on the panel, But after minimizing the form and show again the line disappear in the other hands, after refreshing form all graphic objects will be disappear.
What is your recommendation for permanent graphic object in the form?
Best Regards,
Reza Shojaee
modified on Wednesday, August 19, 2009 1:01 AM
|
|
|
|
|
You are using the CreateGraphics method. This is completely useless unless you're drawing something temporary. Handle the Paint event and draw your line there, that's what it is for
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.
|
|
|
|
|
i'm trying to create a question using a given paragraph dynamically, is there any one who has done this kind of function, at the moment i'm trying to do it using templates , but it doesn't seem to be work fine.
|
|
|
|
|
I've read this five times and I still have no idea what you mean. you want to take a random paragraph and rephrase it as a question ?
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.
|
|
|
|
|