|
I am not sure what you are trying to achieve, but if you want to put the path in a text box so teh user can't then change it, the set the ReadOnly property of the text box to true.
The still leave the question: why put it in a text box if you don;t want the user to change it? Why not use something the user isn't used to changing - a label?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
It's not a matter of the user changing it - it's that I want it to still be there when the application is closed and reopened. The reason for this is there are text files that are in the program. When you create the text files they are assigned the full path of the application. To access those files I have to hard code the paths in the program. Now some other user stores it in his computer someplace different than me and the paths are all wrong. This way I use a folderbrowserdialog to find the path. I chose a textbox for convenience but the idea is to only have to do this once...not every time you open the application. If after doing it the first time if the properties of the textbox text are that path it is loaded right into the program. Hopes this makes sense.
|
|
|
|
|
1) Right click your project, and select "Add...New Item...Application Configuration File"
2) Add a reference to "System.Configuration.dll", and import the System.Configuration namespace to your .CS file.
3) Double Click your app.config file, and make it look like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyFieldName" value="MyField"/>
</appSettings>
</configuration>
4) Load existing path with:
string s = ConfigurationManager.AppSettings["MyFieldName"];
5) Save new path with:
ConfigurationManager.AppSettings["MyFieldName"] = "MyFieldValue";
There are other ways to use application config in .NET, but that one is easy to explain!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thanks very much for all your time
I'll try what you just sent me.
|
|
|
|
|
Please ignore the previous post - I was in a hurry, and cocked it up completely!
Don't use App.Config, use Settings.Settings instead (App.config will work, but it is harder to save new values, the way I described does not work!)
1) Open your projects Properties in the solution explorer, and double click on "Settings.settings"
2) In the resulting grid, change the Name to "MySetting", and set the Value to "Defaulted value". Leave Type and Scope as sting and User respectively.
3) Save and close the settings window.
4) To read your setting:
string s = Properties.Settings.Default.MySetting;
5) To write your setting:
Properties.Settings.Default.MySetting = "My new setting value";
Properties.Settings.Default.Save();
Sorry about that - in my defence I was in hurry!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thanks. Where do I write that code? I assume the information in quotes would be my information?
|
|
|
|
|
Anywhere you like!
I would suggest loading the path into the TextBox on form load (and put it into the SelectedPath property of the FolderBrowserDialog as well).
Then when the user presses the OK button in the FolderBrowserDialog, load up the TextBox, and save the new path.
You can replace "MySetting" with your own name(s), and the same for "Defaulted value" and "My new setting value". So if you want a setting called "ThisIsThePathTheIdiotUserWantsMeToUse", you can, and access it via
string s = Properties.Settings.Default.ThisIsThePathTheIdiotUserWantsMeToUse;
However, I wouldn't recommend it as the settings file is in XML and is thus human readable...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Ok Great! Thanks for all your help
|
|
|
|
|
i have an assembly delayed signed using "key.snk". i extracted the public key from this and it is stored in "pubkey.snk".this assembly is running well in local pc , but when deploy in other pc with pubkey.snk , get the exception , and doesn't run, when it is not signed it works well on other pcs.can anyone help me with this...
|
|
|
|
|
while (WebBrowser.IsBusy == true)
{
Application.DoEvents();
}
Im using the code above in a documentcompleted method (a html form has to be submitted) to wait until the WebBrowser is finished loading the document which works but its sucking up all the processor's cycles. Is there any to limit checking to once a second without splitting the method up or using events ?
|
|
|
|
|
BuggingMe wrote: I...without splitting the method up or using events ?
Basically no and why would would you not want to use proper techniques? You should have a background thread or use an AutoResetEvent or ManualResetEvent
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Well no navigation is taking place so i cant use the navigated event, After the submit button is clicked there is a delay of an unknown length and text is injected into the HTML page via PHP. Here is the code im using to detect this, It works but is very CPU intensive
<pre>while (WebBrowser.IsBusy == true)
{
Application.DoEvents();
}
string InitalPage = WebBrowser.DocumentText;
while (WebBrowser.DocumentText == InitalPage)
{
Application.DoEvents();
}
while (WebBrowser.IsBusy == true)
{
Application.DoEvents();
}</pre>
I haven't learned threading yet (something i definitly want to avoid if at all possible for this project), There's no documenttextchanged event to use so im not sure what to do now
IS there any non CPU intensive/Non threading alternitive to the above code?
|
|
|
|
|
BuggingMe wrote: I haven't learned threading yet
Time to start
BuggingMe wrote: something i definitly want to avoid if at all possible for this project
And why would that be? Use the proper tools for the job.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
BuggingMe wrote: avoid if at all possible
Perhaps you're unaware that your code is using one? You need to understand what you are doing to the application's main thread at least.
|
|
|
|
|
While the proper way would be to use events or a background thread, you can hack it up with crappy code and do this.
while (WebBrowser.IsBusy)
{
Application.DoEvents();
System.Threading.Thread.Sleep(500);
}
|
|
|
|
|
This is the perfect time to start learning Threading....
|
|
|
|
|
Ok so I posted this a while ago and I need to reiterate the question:
In panelMasterlist I have a delete event:
public void contextDeleteMasterList_Click(object sender, EventArgs e)
{
frmGenericProgress F = sender as frmGenericProgress;
List<MasterListItem> deletedObjects = new List<MasterListItem>(); .............}
It populates a list then validates it... etc.
In frmMain
I have a button event from a 3rd component that when triggered need to do the exact same thing done in contextDeleteMasterList_Click.
private void buttonDeleteMasterlist_Activate(object sender, EventArgs e)
{
So I made the contextDeleteMasterList_Click public, and in the buttonDeleteMasterlist_Activate tried calling
private void buttonDeleteMasterlist_Activate(object sender, EventArgs e)
{
panelMasterlist.contextDeleteMasterList_Click();
}
got Error 1 No overload for method 'contextDeleteMasterList_Click' takes '0' arguments
tried:
private void buttonDeleteMasterlist_Activate(object sender, EventArgs e)
{
panelMasterlist.contextDeleteMasterList_Click(sender, e);
}
got Error 1 An object reference is required for the nonstatic field, method, or property 'Freepour.Studio.Forms.Panels.panelMasterlist.contextDeleteMasterList_Click(object, System.EventArgs)
Any help is greatly appreciated
|
|
|
|
|
try:
panelMasterlist.contextDeleteMasterList_Click(null, null);
[Added]
My bad. Wasn't reading carefully.
You need to either create a new instance of PanelMasterList and then call the method
such as
....MasterPanelList mpl = new MasterPanleList();
mpl.contextDeleteMasterList_Click(null, null);
or create and use a delegate to call that method.
Or make the method/event handler static. But this really is a bad practice.
[/Added]
|
|
|
|
|
Thank you first method worked!
|
|
|
|
|
The first error tells you you try to use a method with a wrong signature.
The second error tells you the method you're trying to use is not static (i.e. you can't access it from its class, you have to use an instance of the panelMasterList to call the method).
So, if your main form holds an instance of panelMasterList, use the variable referencing this instance to call the method :
myPanelMasterList.contextDeleteMasterList_Click(sender, e);
Or make the method static in the panelMasterList Class :
public static void contextDeleteMasterList_Click(object sender, EventArgs e) {...}
But, depending on how you organized your application, there could be some more issues. This is only what I can think of regarding the informations you provided.
Kind regards.
|
|
|
|
|
Hi all
I have googled it for days now I can only find information on how to get the ActiveMdiChild form from the main MDI form(parent).
I have a MDI application with a few children and a non child form that is used to update data on the active child.
In Borland Delphi you could add the following to any form Parent or not and it will allow you access to that selected child's controls.
Delphi
______
TfMDIChild(fMainForm.ActiveMDIChild).Label1.caption := 'Some text';
Is there any way to do this in C#
Ta
|
|
|
|
|
Deneys wrote: Is there any way to do this in C#
That would roughly translate to this;
(this.ActiveMdiChild as FormTableBrowser).Label1.Text = "Some Text"; "this" pointing to the mainform, which has a ActiveMdiChild property. That's a form that can be casted, just like we did in Delphi. A big difference is that "Label1" has become "label1", it's private by default. You can change this by setting the Modifiers -property in the designer to public .
Hope this helps
I are Troll
|
|
|
|
|
I have around 1.5 million words/phrases. I have to search these words/phrases in the text file which contains more than 1000 pages. If words/phrases are found then I need the position of the words/phrases. Can anybody get me the search logic which works faster.
Thanks in Advance.
|
|
|
|
|
K Suresh Reddy wrote: I have around 1.5 million words/phrases. I have to search these words/phrases in the text file which contains more than 1000 pages. If words/phrases are found then I need the position of the words/phrases. Can anybody get me the search logic which works faster.
An algorithm like Boyer-Moore? Or more a technique, like caching?
There's several options, depending on your needs. In general, an ad-hoc search would be slow, and this can be improved by preparing an index in advance, listing in what pages each word occurs. This would look something like a table;
Word Page
------- --------
1 1,2,6,9
2 1,3,4
3 1,2,3,9 Sql Express has a text-indexing feature[^], that might save some time, compared to indexing the words by hand. Another advantage is that the resultset would be available to multiple clients; I imagine that you'll need lots of CPU-power to process the results.
I are Troll
|
|
|
|
|
Hello everyone,
My problem is as follows:
- When I select text in a textbox I want the following things happen:
example: I select the word "hello", and pressing a button I want the selected word becomes
"[b]hello[/b]".
How can I do? (I speak of a web application not windows form)!
Please help me!!!
|
|
|
|