|
|
how would i add a string were the current index is(caret)??
IM PROUD TO BE A GMAIL;
|
|
|
|
|
The string class has an Insert method that takes an int specifying the index at which to insert the new string and the string to insert. TextBox.SelectionStart will give you index where the caret is currently located if there is no text selected, or the beginning of the selection if there is. You'll probably want to replace the selected text if there is any. You'd use String.Remove for that.
Charlie
if(!curlies){ return; }
|
|
|
|
|
thanks
IM PROUD TO BE A GMAIL;
|
|
|
|
|
can you help me since im using .net v2.0 and this might be a bug but...
if (textBox1.SelectionLength != 0)<br />
{<br />
textBox1.Text.Remove(textBox1.SelectionStart, textBox1.SelectionLength);<br />
}<br />
textBox1.Text.Insert(textBox1.SelectionStart, tempstring);
(it doesn't work for me)
IM PROUD TO BE A GMAIL;
|
|
|
|
|
It's not a bug. Strings in .NET are immutable, which means they cannot be changed once they are initialized. Calling Insert or Remove on a string does not change the object on which the method was called; It returns a new string with the new value.
string s1 = "This is a string.";
string s2 = s1.Insert(10, "new ");
Console.WriteLine(s1);
Console.WriteLine(s2);
If you do want to change the string that s1 references, you'd assign the return value from the method you're calling to it.
string s1 = "This is a string.";
s1 = s1.Insert(10, "new ");
Console.WriteLine(s1);
Charlie
if(!curlies){ return; }
|
|
|
|
|
crap, thanks again, i still getting used to the .net framework
IM PROUD TO BE A GMAIL;
|
|
|
|
|
I am trying to solve these 2 exercises. I don't know where to start.
Could someone please help me with the start and sample code?
Exercise 18-1: Write a module that will handle page formatting. It should contain the following functions: open_file(char *name) Open print file. define_header(char *heading) Define heading text. print_line(char *line) Send line to file. page(void) Start new page. close_file(void) Close printer file. ----------------
Exercise 18-2: Write a module called search_open that is given an array of filenames, searches until it finds one file that exists, and then opens the file. ---------------- DO NOT FORGET TO WRITE RESPECTIVE MAIN MODULES
|
|
|
|
|
You should attempt your homework first. Your tutor should have given you all the materials you need to complete the exercise already. If you get stuck on your attempt, please post with a specific question about a specific problem you are having. Do not just post your homework questions and expect someone to answer; you will not learn anything that way.
Finally, when you do have a specific problem, please post it to the correct forum. This forum is for questions on C#, not C.
Do you want to know more?
|
|
|
|
|
Hi!
I am writing a client/server application that uses sockets as the network interface. When I, in the client code, try to connect to the server by using BeginConnect with the wrong IP-address, my form freezes immediately and remains that way until an exception is thrown. Is there any way to prevent this from happening? Can I control how how long before the exception is thrown? I was using the construct below to solve the timeout issue, but that does not restore the state of my form. I assume the BeginConnect must be interrupted in some way, but I don't know if that can be done?
IAsyncResult connResult = this.remoteHost.BeginConnect(
remoteEndPoint, null, null );
// wait until the BeginConnect finishes
if ( connResult.AsyncWaitHandle.WaitOne(timeOut, false ) )
{
}
else
{
// WaitOne timed out
}
|
|
|
|
|
|
I would like to create a structure with fixed length strings. Is this possible?
For example the first element in the structure needs to be 20 characters etc.
Thanks for any help.
|
|
|
|
|
the code may me like this if u will control it in another method
struct urOne
{
string x = "";
}
void urMethod()
{
urOne.x = "asdfasdasd";
if (urOne.x.Length!= 20)
{
return
}
}
or do this method in the struct it self
ByMindOnlyYouCanDoIt
|
|
|
|
|
Hi all,
How should I mimic the ComboBox DisplayMember property which gets a string and can use the property whose name is indicated by that string.
Thanks in advance
|
|
|
|
|
When you know the name of the property, you can invoke that using Reflection (System.Reflection)
Type.GetType("MyType").GetProperty("MyProperty").GetValue
|
|
|
|
|
I am buIlding a library for developers so I dont know the type of the object.
And another problem , in GetValue Method there is an object and an array of indexes that I couldnt give a meaning.
Could you give me a real example please.
|
|
|
|
|
Hi,
I need to show the phone number of the caller in a c# program, I have CTI Meteor.
Any one can help?
Thanks
|
|
|
|
|
help on what? be more specific
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Tom, thanks for response.
I need to make a program which can display the caller number when a phone call is recieved, having ofcourse the display modem attached to the COM port and the phone line, I have the modem (PC Caller ID).
Do you have any idea on how to show that?
Cheers
|
|
|
|
|
go to msdn or google hardware programming, im sorry i don't have time right now to do it my self
IM PROUD TO BE A GMAIL;
|
|
|
|
|
This is usually done through TAPI, if your modem supports it.
However TAPI and C# don't go very well together. You will be better off using C++.
However if you must try and use TAPI and C#, you are best off using this[^] as a starting point.
Michael
CP Blog [^]
|
|
|
|
|
Hi,
I just began learning c#, so I hope I am giving enough info with my question. I created a solution with two projects, in one I have an Mdi frame (with one namespace: boekhoud, and one class: frmContainer), in the other I have a child (with one namespace: ClientOnderhoud, and one class: frmClient). I set the parent-childrelation with
frmClient child = new frmClient();
child.MdiParent = this;
child.Show();
This compiles allright, so I can reference frmClient in my parent.
Now I would like to reference frmContainer in my child, I do this with
((frmContainer)this.MdiParent.MyConnection).Open();
It gives me the following error:
The type or namespace name 'frmContainer' could not be found (are you missing a using directive or an assembly reference?)
What should I do to let this work?
regards,
Stefan.
|
|
|
|
|
if projects are different then u have to:
1. add a reference to the Mdi Frame project in the child project. U can do this through the solution explorer >> Add reference >> and choosing the Projects tab.
2. Add a using statement at the beginning of ur child class file:
using boekhoud;
|
|
|
|
|
Ola Skynyrd,
I cannot add a reference to the mdi frame project, as it is no dll (I get an errormessage saying so if I try). I follow the rule 'an exe for the mdi, dll's for the childs'. With using boekhoud in my child cs I get 'The type or namespace name 'boekhoud' could not be found (are you missing a using directive or an assembly reference?)'
Any other ideas?
Gracias,
Stefan.
regards,
Stefan.
|
|
|
|
|
u need to have both projects under the same solution. Once u do this, u can reference projects through the projects tab even if they are .exe
Create a blank solution and add both projects to it. Then go to add references, and under the project tab of the Add References Dialog u will see that u can add a reference to the other projects of ur solution. DO NOT try adding it through the NET tab as u will get the exe error.
|
|
|
|