|
The cleanest way to do this is by the use of delegates[^]. You create a public delegate in Form1 which Form2 can subscribe to, then when the textbox content changes, Form2 will get notified of the change and can copy the content into its own variable.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
thanks dear, but may u show me how?
give me an example by writing a short codes.
|
|
|
|
|
Try this:
public class Form1 : Form
{
public delegate void StringTransportingEvent(string value);
public event StringTransportingEvent VariableChanged;
override void OnLoad()
{
Form2 secondForm = new Form2(this);
secondForm.Show();
}
textBox1_TextChanged(object sender, EventArgs e)
{
EventHandler eh = VariableChanged;
if( eh != null)
{
eh(textBox1.Text);
}
}
}
public class Fomr2 : Form
{
public Form2(Form1 eventRaiser)
{
eventRaiser.VariableChanged += Form1_VariableChanged;
}
private void Form1_VariableChanged(string value)
{
this.TextBox1.Text = value;
}
}
It creates a custom delegate that can transport a string .
Form1 raises a custom event "VariableChanged " that Form2 subscribes to.
Ciao,
luker
|
|
|
|
|
thanks LUK, I think got it. this was a question that
had occupied my mind for many days. and u solved it
for me. thank a lot again. persons like u rich this forum.
|
|
|
|
|
If you go to the link I posted you will see a very comprehensive tutorial on the subject. While it does not answer your question directly, it is a good learning tool to help in developing your skills.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
faraz34 wrote: but i didn't get an explicit answer
Yes you did. What you didn't get was an exact code sample you could copy'n'adapt to your code. Luc's link was very explicit and explained the concepts quite clearly.
By doing this you are also making your forms completely dependant on one another. You now cannot change one form without affecting the other. This means you have a very bad data model. You shouldn't be accessing controls on one form from another. You should be putting the data from that form in a container object so that it can be passed back to or retrieved by the calling code.
|
|
|
|
|
|
Unless it's your wife, you don't call anyone in the Western world "dear".
|
|
|
|
|
Your original post contains some really good answers that can help you achieve what you are trying to accomplish. But your problem is that you expect too much spoon feeding and if this is the case, you're not going to stop littering the forum by asking the same question again and again until someone writes the entire code for you for free.
People here try to teach you how to fish, but you're expecting the fish itself everytime. Pathetic.
|
|
|
|
|
Hello All,
I have used 4 textboxes & 3 dropdownlists to filter the Gridview.
Now I want to filter Pie CHART By all those same filter parameters.
Can any1 please help me for that ???
Its urgent...
Thank you in advance...
|
|
|
|
|
Hello Every one;
I'm using telerik Radeditor.When i save in the data base(SQLSERVER),i save the Content(contain HTML balises).
when i export th word document,i can't interpreat those html balise.
Best Regards,
Helmi
|
|
|
|
|
When it comes to vendor issues, you are usually better off going to their support[^] forums. Telerik has one of the finest support systems in the industry, so I would recommend that you ask your question there. Oh, and include some code when you do - they, just like us, aren't mind readers.
|
|
|
|
|
|
HiIam santhoshkumar.
Can u any body tell me How to use mvc in asp.net?
Now learning in it.
|
|
|
|
|
See here[^] for explanations and samples.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
How to set up dataGridView background image, or transparent background
|
|
|
|
|
By painting[^] it; it's not provided as default functionality.
Bastard Programmer from Hell
|
|
|
|
|
Can you provide a detailed drawing code?
|
|
|
|
|
On demand;
class MyDgv : DataGridView
{
public override Image BackgroundImage
{
get
{
return base.BackgroundImage;
}
set
{
base.BackgroundImage = value;
}
}
protected override void PaintBackground(
Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
{
base.PaintBackground(graphics, clipBounds, gridBounds);
graphics.DrawImage(BackgroundImage, new Point(0, 0));
}
}
public partial class Form1 : Form
{
MyDgv _dgv = new MyDgv();
public Form1()
{
InitializeComponent();
_dgv.Dock = DockStyle.Fill;
_dgv.BackgroundImage = Image.FromFile(
@"C:\Users\Eddy PC\Pictures\untitled.bmp");
_dgv.DataSource = new List<DateTime>() {
DateTime.MinValue,
DateTime.Now,
DateTime.MaxValue };
this.Controls.Add(_dgv);
}
}
Bastard Programmer from Hell
|
|
|
|
|
bonsoir, je suis entrain de développer une application desktup avec le c# et j’essaye d me connecter avec un serveur sur un hébergeur gratuit 000webhost...bref j n’arrive pas à me connecter malgré j'ai essayer avec diver connecteur sql je travaille avec VS2010 , avec sql server 2008 , FW 4.0
voilà la chaine de cnx:
cnx = new MySqlConnection("Server=...;Port=3306;database=...;Uid=...;password=..."); merci d'avance
DotNeting ^_^
|
|
|
|
|
Non! This is an English speaking website so though I get a lot of what you are asking some of it is unclear. Problem with your connection string? Can you translate to English?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Google translate sort of works
Good evening, I am trying to develop an application desktup with c # and I try to connect to a server on a free 000webhost short j ... can not connect me despite I try with sql connector diver I working with VS2010, with sql server 2008, FW 4.0
this is the cnx chain:
cnx = new MySqlConnection ("Server = ...; Port = 3306, database = ...; Uid = ..., password = ..."); thank you in advance
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Maybe this[^] can help.
You ought to check your server is reachable, pingable, etc. There may be obstacles, such as FireWalls either side.
|
|
|
|
|
Free website-hosts don't allow remote connections to the database. You could try using a web service to interact with the site.
Bastard Programmer from Hell
|
|
|
|
|
When the user click on sort button in a form, the a new small form will popup. There all the column of the datagridview will be listed. But that each column name should be enabled to drag and drop to make the sorting order . On the basis of the order of drag and drop , the datagridview should be sorted
I am new in C# so I donot know how to impliement in C#
Please help
modified 23-Feb-12 18:34pm.
|
|
|
|