|
|
Hello
I have a form where there is plenty of textbox after sving the data
I want to empty all these textbox.
how I can do that by foreach statment
or if any one have another idea, will be greatly appreciated
instead of empty each one alone
thanks in advance
Assaf
|
|
|
|
|
In your form you could do something like:
foreach (Control control in this.Controls)
{
if (control is TextBox)
control.Text = string.Empty;
}
|
|
|
|
|
<br />
foreach (Control c in this.controls)<br />
{<br />
if (c is TextBox)<br />
c.Text="";<br />
}<br />
|
|
|
|
|
foreach (Control c in this.Controls)
{
if (c is TextBox)
c.Text = new string('0', 0);
}
Sorry
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Sigh. I feel like such a newb.
Ok, as the subject suggests I have a parent form that passes two values to a sub form. I want to edit the values on the sub form, and pass these updated values back to the parent form.
I can get the values to the sub form, but not back to the parent form... I just can't figure out how to make this happen. I get two errors:
Error 1 An object reference is required for the nonstatic field, method, or property 'WindowsApplication7.Form2.stAptUnitNum'
Error 2 An object reference is required for the nonstatic field, method, or property 'WindowsApplication7.Form2.stAddress'
I presume this means I am a rookie, er, I mean that I am doing something fundementally wrong, because to be honest even after googling this problem for over an hour I can't find an explanation that I understand. I thought making the two variables public on form2 would allow me to get their value when back to form1, but perhaps not.
On the main form:
<br />
private void fxn_reevaluate()<br />
{<br />
Form2 frm = new Form2(stAptUnitNum, stAddress);<br />
frm.ShowDialog();<br />
stAptUnitNum = Form2.stAptUnitNum;
stAddress = Form2.stAddress;
}
which then calls the sub form...
<br />
public Form2(string Address1, string Address2)<br />
{<br />
InitializeComponent();<br />
textBoxAddr1.Text = Address1;<br />
textBoxAddr2.Text = Address2;<br />
}<br />
<br />
public string stAptUnitNum;<br />
public string stAddress;<br />
<br />
private void btnSubmit_Click(object sender, EventArgs e)<br />
{<br />
stAptUnitNum = textBoxAddr1.Text.Trim();<br />
stAddress = textBoxAddr2.Text.Trim();<br />
this.Close();<br />
}<br />
Any help would be greatly appreciated.
Thanks!
-Matt G.
|
|
|
|
|
|
You know, I really did read this article, and unless I am overlooking something, or failing to infer something, all I see here is pass value from parent to child (which I thankfully have working), update child from parent when child form is open (cool, but I am not there yet...) and passing values from children to child (sibling to sibling).
Am I overlooking something that shows how to get a value back from a child to the parent?
Thanks!
-Matt G.
[edited for spelling...]
|
|
|
|
|
Yes, read the 'Sibling to Sibling' chapter.
"... This also demonstrates passing between the child and the parent."
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Oh geez. Clearly I need to take a breath and read more slowly...
Thanks!
|
|
|
|
|
madEG wrote: Clearly I need to take a breath and read more slowly...
I know what you mean
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
You didn't declare the properties "stAptUnitNum" and "stAddress" as static. You must call them from the instance, like
frm.stAptUnitNum
frm.stAddress
instead of calling them on the class, like
Form2.stAptUnitNum
Form2.stAddress
Hope this helps.
Jeff
|
|
|
|
|
I find the easiest way to do this is to change the subform's constructor and pass the control or variable or even the parent form in that.
|
|
|
|
|
There would be no need to pass public variables or the parent form through the constructor, since the child form has access through this.Parent
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Hi. I'm having trouble using streamwriter on certain files because those files contain chinese characters. I can fix my problem, but only in a way that it'll work correctly for one or the other, but not both at the same time.
The main issue is that I need to write to files that do not contain chinese, and files that do contain chinese. These files are mixed together, and at times there can be 500+ files. The only way to tell them apart that I can think of is to check if the file uses a certain font.
The files that contain chinese characters display them using the SimSun font. The files that do not have chinese characters do not use the SimSun font.
How can I check a file to see if it uses a certain type of font? I just need pointed in the right direction. I've tried messing around with iTextSharp but it doesn't seem to be able to read files, just write to them.
|
|
|
|
|
Can't you check the encoding that the text file uses?
For example, Unicode(UTF-8) or Greek (ISO) or Arabic (DOS).
Or is the encoding all the same, and its just the font that provides the chinese characters?
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
I don't know how if it's possible.
All I could find on that was "EncodingInfo GetEncodings" or something, which I tried on a file containing chinese and a file that had just 1 character of english. They both returned about 30 codepages... all of which were exactly the same.
*shrug*
|
|
|
|
|
Hello everyone,
I have created a BHO using C#. The code works fine. I would like to detect mouse click on a particular bytton. The following is the SiteSet().
public class BHO : IObjectWithSite<br />
{<br />
private SHDocVw.WebBrowser webBrowser;<br />
private mshtml.HTMLDocument document;<br />
private mshtml.IHTMLDocument2 document2;<br />
private mshtml.HTMLElementEvents_Event events;<br />
<br />
public int SetSite(object site)<br />
{<br />
if (site != null)<br />
{<br />
webBrowser = (SHDocVw.WebBrowser)site;<br />
webBrowser.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);<br />
webBrowser.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);<br />
<br />
webBrowser.OnQuit += new SHDocVw.DWebBrowserEvents2_OnQuitEventHandler(this.OnQuit);<br />
webBrowser.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.NavigateComplete2); <br />
<br />
events.onclick += new mshtml.HTMLElementEvents_onclickEventHandler(this.OnElementMouseClick); <br />
<br />
}
for the OnElementMouseClick function I have the following.
public bool OnElementMouseClick()<br />
{<br />
MessageBox.Show("HelloWorld...");<br />
return true;<br />
}<br />
.<br />
.<br />
.<br />
.<br />
But nothing really happens! Am I wrong to think that the above code should give me HelloWorld message once a button is click?
Any information on this would be appriciated. Thank you very much.
Khoramdin
|
|
|
|
|
|
Hello,
You should POST the entire message rather than posting one section of it. If I remeber correctly, I said "If my messages bother you so much I surly can stop and take my postings and problems to another forum.". That is if you wish to be fare, mate!
I still stand by my posting as I am not here to upset anyone.
By the way, didn't take your advise and managed to solve the problem. Hey, not all of use get Free MVP title! *wink*
Thank you for the reply.
Khoramdin
|
|
|
|
|
Khoramdin wrote: You should POST the entire message
You mean like the like above the reference?
Khoramdin wrote: By the way, didn't take your advise and managed to solve the problem.
Good for you. It is helpful to others to post the solution. If indeed you have solved it yourself. Perhaps someone with more experience just finished it for you. "wink*
only two letters away from being an asset
|
|
|
|
|
ha ha ha...
I wish someone had solved it for me, mate! I truly cracked my head on that BHO and believe me when I tell you that I was so excited when it got working!
I cannot deny the fact that I read nearly a milliion posting and articles before I managed to get it up and running.
I am actually thinking of creating a STEP BY STEP and detailed tutorial and submit it to codeproject regarding the BHO. My finding was that, expect one or two articles; there isn't much of information on BHO on Internet.
It is good to see you have a delightful sense of humor. Happy thanx-giving, mate.
Khoramdin
|
|
|
|
|
how I can insert image into sqlserver database with c#.
|
|
|
|
|
how I can insert image into sqlserver database with c#.Ineed the code
|
|
|
|
|