|
private void SomeFunction()
{
string var = "your string";
yourtextbox.focus();
SendKeys.Send(var);
}
|
|
|
|
|
Hi everyone.
I've got a listBox and a list of elements in it.
I've got another windows form, and it will be created after an item in the listBox is double clicked.
What I'm asking is;
I want to "read" the name of the element from the list box, and then fill the new form according to this information.
How can I pass the listBox1's selected Item's text to the new form?
can anybody help?
|
|
|
|
|
Create a constructor for the new form that takes the information necessary.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Oh I've not created a constructor about 3 years, I don't remember how to but I'll try,
I'll try the articles
|
|
|
|
|
You need to research articles to create a class constructor?!?
Go read some books, take a class, whatever it takes but stop trying to write applications until you do.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
ahhaah just never needed to create one until now =) (just graduated)
take it easy, thanks for help and advice
|
|
|
|
|
Just graduated? And this wasn't covered? Where did you graduate from?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
tatarrullaz wrote: just graduated
You should go right back to school. I'd written more constructors than I can count before I even started my first year at university. You have no excuse.
|
|
|
|
|
You can just simply write a custom property method for that.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
you mean a public class that can be reached from the new form?
is this it?
|
|
|
|
|
Yes, but it depends on how you are going to use the class... you can also use a constructor.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
That would be awful IMHO if all you need is to send selected item. You should used a parameterized constructor. Or have a public event handler so that you can handle the double click event in the Form where you need to get the selected value.
Constructor would be the simplest way though.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
class Form2 {
private string m_Data;
internal Form2(string data) {
m_Data = data;
}
private void Form2_Load(...) {
Use m_Data here........
}
}
class Form1 {
private void ListBox1_DoubleClick(...) {
Form2 f2 = new Form2(ListBox1.SelectedText);
f2.Show();
}
}
|
|
|
|
|
"Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime"
Same goes for code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You are right. Until they know what a fish is, we have to give them fish
|
|
|
|
|
No, you missed the point. We don't give them the code, we teach them to code.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
SelectedObject = GetSelectedObjectFromListBox();<br />
MyPopUpForm form = new MyPopUpForm();<br />
form.SelectedObject = SelectedObject;<br />
form.Show();
or
SelectedObject = GetSelectedObjectFromListBox();<br />
MyPopUpForm form = new MyPopUpForm(SelectedObject );<br />
form.Show();
depending on your preference.
In the 1st case you need a public property in your popup form, called SelectedObject. In the setter, you need to do what you need to do.
In the 2nd case you need a constructor that takes a SelectedObject as a parameter. It is usually inadvisable to use this constructor to populate your form - store it then populate when the form is shown.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I'm trying to figure out how to tell if a feature is install on Vista SP1 and newer OSs. does anyone know where this is stored at?
i need to check if the Group policy management features are installed, it is not listed in the registry for add remove programs...
thanks
|
|
|
|
|
Hi
In codebehind i want to know when my checkbox become unchecked?
|
|
|
|
|
The documentation will be able to show you how to do this, but you can check using
if (checkbox1.checked == true)
else
Also, make sure to check that your checkbox is not a three-state checkbox.
Clickity[^]
Also, make sure to use Liquid Nitrogen properly next time.
|
|
|
|
|
No;
I need an event that occur when a checkbox become unchecked;
|
|
|
|
|
Well... you can create the event anonymously using
checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
Or you can have visual studio add the event and delegate for you by (through designer) selecting a checkbox on your form, going to its events and double clicking the CheckChanged property. This will, like all other events added through this method, create the event handler for you in the designer file and create a method stub for you.
Or you can add the delegate and event handler yourself using the code above...
|
|
|
|
|
If you are talking about ASP.NET, you need to set the AutoPostback property of the CheckBox to true and then handle the CheckedChanged event.
|
|
|
|
|
I work in windows application
|
|
|
|
|
I already told you how to do this above.
|
|
|
|