|
Try the following:
string s = "oldstring";
s = s.Replace("old","new");
If you look at the value of 's' it should now be "newstring".
I hope this helps.
|
|
|
|
|
Thanks for all the help here guys; I'm having a play with with the StringBuilder class' replace overload (StringBuilder.Replace Method (String, String, Int32, Int32)), as this seems to fit the bill - and is a lot more powerful than the generic String.Replace method.
|
|
|
|
|
Sir,
i am 2 using a datagrid's in one form
1) in the first datagrid i want to have a dynamic insertion of a new row with the click of the insert button & with in that datagrid i have 2dropdown lists from 2 different tables and 3 textboxes. and i also want to store the data entered in the each row into database.NOTE there is no datakey field for the datagrid
1 2 3 4 5
Resources -- Tasks -- Estimated Hrs -- Start Date--End Date
DropDown DDown txtbox txtbox txtbox
2) in this datagrid i have 6 columns. in first 2 columns data is to be retrived from the database in 3rd colums values is fixed ,4-5 columns are to be calculated.i am writeing brief about it down
===========================================================================
1 2 3 4 5 6
Resources--Avaliable Hours--Assigned Hours--Calender Hours--FromDate-startDat
Calender Hours=fixed
avaliable hours=calender hours-assigned hours
Plese Read it
-- modified at 6:44 Wednesday 17th May, 2006
|
|
|
|
|
Hi there.
I've found plenty of samples on how to implement dragging and dropping TO a winform in C#, and I've gotten that part to work. But the other way around (FROM a winform TO explorer) ... no luck
I only found one article on TheCodeProject, but that was using C++
Any pointers or links would be very much appreciated.
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob Lund Krarup wrote: I only found one article on TheCodeProject
You probably have to search a bit better
This[^] and this[^] article are also about dragging into the explorer (or desktop which essentially is the explorer).
|
|
|
|
|
Hehe.. yes - you're right, I probably have to search a bit better
One of those articles is brand-new by the way. It's great how often that happens to me ... I need a specific functionality, and Wonder of Wonders ... it pops up as an article on the CodeProject
Thanks for the links Robert!
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
hi all,
i have 2 forms one is main (frmTerminal) and the other (ChangeSettings) is is called when one clicks on the Settings option under menustrip.
there are some textboxes, comboboxes and radioboxes on frmTerminal but i want to change these value through Settings form...
how can i change the values on form1(frmTerminal) through the second form (ChangeSettings) ?
would you please help me do this
many thanks in advance,
bye.
example: on frmTerminal i've textbox1, combobox1, and 2 radioboxes. and same on ChangeSettings...
|
|
|
|
|
Hi there Mehmet
The problem you're posing is actually about encapsulation in OOP (Object Oriented Programming), so it might help you to think about it in this way:
Let's say you have two classes: A and B, and B has to be able to alter A in some way.
The only way for B to be able to alter A is if:
1) B knows A (has a reference to it)
2) A lets B access the variables B wants to change
You can accomplish part 1 by adding a constructor to form B which accepts A as a parameter and then stores a reference to A:
public class frmChangeSettings
{
private frmTerminal _theTerminalForm;
public frmChangeSettings(frmTerminal theMainForm)
{
this._theTerminalForm = theMainForm;
}
}
You can accomplish part 2 by adding properties to frmChangeSettings
public class frmTerminal
{
public string TextBox1sText
{
get {return this.TextBox1.Text;}
set {this.TextBox1.Text = value;}
}
}
Then when you want to change something (for example the text in TextBox1) on from frmChangeSettings, then you just use
this._theTerminalForm.TextBox1sText = "something something"
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Message Closed
modified 27-Apr-15 11:03am.
|
|
|
|
|
Hi Mehmet
I don't understand your question.
Do you mean - how to change the User Interface, or parameters, etc. on the new form ("mehmet" in your example)?
In that case, you do it the same way:
Create public properties on the Form1, that way you can use these parameters to change the values on the newly opened form:
Here is a fragment of the newly opened form
public class FormSettings : Form
{
private TextBox txtName;
public string Name
{
get {return this.txtName.Text;}
set {this.txtName.Text = value;}
}
}
Here is your code, with added code to change what text is displayed in the textbox shown above:
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 mehmet = new Form1();
mehmet.Show();
mehmet.Name = "A name...";
}
Hope this helps
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Hi guys,
I have a datagrid control in my c# application and I want to select more than one cell at same time,
the problem is that the control not allow to do it.
If someone know how to do it please help me!!!!
Thankyou a lot in advance.
Mirko.
|
|
|
|
|
Hello there
I have a string with one line repeating after every 10 lines
I want to replace the first line only and let the other as its.
the problem is when I use variable.replace(findString,ReplaceString);
it replaces all.
can anyt one tell me how to replace the first string only
Rizwan Bashir
|
|
|
|
|
I think you have to use IndexOf to find the position of the searched string, then use SubString to get the left and right parts of the string and finally concat everything together.
|
|
|
|
|
Hi,
It is simple. First use the IndexOf method to find the index of the sring. then using length property just remove the string to be replaced. then insert new string at the same index from where we first removed the string.
Hope this algo works. i havent checked but its the only solution i could figure out.
Anant Y. Kulkarni
|
|
|
|
|
The RegEx.Replace method can replace a specific number of occurances:
variable = new RegEx(RegEx.Escape(findString)).Replace(variable, ReplaceString, 1);
If ReplaceString contains any $ characters they have to be replaced by $$.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
if you are planning to perform number of successive operations on strings, then it is recommended that you use the StringBuilder class. It will help your program performance. This class is somehwere in the Text namespace i think. try searching for it in MSDN or google.
Anant Y. Kulkarni
|
|
|
|
|
hi all,
i wanna ask somethin about the forms.
let's say i've 3 textbox which hold the info of name, surname and age of a people.
then i place a button Submit. my simple form is finished. but then i want to add another text field to hold email data right up to my Submit button.
when browsing with TAB key, i fill first 3 text box step by step then jump to Submit button and after that cursor places on eMail textbox.
what should i do to fill eMail textbox before jumping to Submit button ?
help please...
ps: for this simple form, it's easy to delete Submit button and place a textbox then put the button on form again so as to achieve what i ask for above.
but what if i work on complex forms? this remove & place operations will undoubtedly severe headaches
|
|
|
|
|
Hi,
You can set the tabindex property of the control to get the desired result.
Hope this will solve your problem.
Best Regards,
Apurva Kaushal
|
|
|
|
|
1) Open form in designer
2) View menu>Tab Order
3) Click on elements in the order you want them tabbed
4) View menu>Tab Order (to switch off)
Job done!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Hi,
Can any body tell me how to set up an interactive service using C# service project...
Regards,
Waqas.
|
|
|
|
|
Hi,
A windows service can be interactive by implementing the OnCustomCommand event in your service. This event is fired when a custom command is send to your service through a ServiceController. You can then implement various logics accordingly in your service so that it turns interactive. For this you will have to create a front end application which has a service controller for your service and then pass custom commands to your service thorugh that controller. the ExecuteCommand statement in the service controller accpets an integer argument denoting your custom command type. you will have to decide over these commands and there numbers to distinguish between.
Hope this helps you.
Anant Y. Kulkarni
|
|
|
|
|
how can i have checkboxes for only child nodes in a windows treeview control? i dont want to have checkbox for all of node.
i used visual2005! thanks !!!
I Love C#/VS2005!
http://justinw.cnblogs.com
-- modified at 8:18 Tuesday 16th May, 2006
|
|
|
|
|
help!
I Love C#/VS2005!
http://justinw.cnblogs.com
|
|
|
|
|
Hi,
I have to draw line with the properties like in MS-WORD like Style and Weight. The Constructor of Pen class ask for Width of Pen in float. How can I relate width to Weight of line. Say I have to draw line of .75 pt then what will be the width of line...
Any idea??
Thanks in advance
|
|
|
|
|
Read about property Graphics.PageUnit and GraphicsUnit enumeration.
Best regards, Alexey.
|
|
|
|