|
Hello, if I have a string object with RTF tags and I want to display it on richTextBox, is there a way to convert it so that the text would appear bolded (for example) instead of the tags for bold?
Mike - I love to program!
|
|
|
|
|
how can i send email using net.mail namespace. it gives me always unreadable adresess error.
Thanks
|
|
|
|
|
if you have same prob you should add
Mesaj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","0");
anybody didnot answer but nop
|
|
|
|
|
I have started a thread. And in the process of this thread I need to show another form and wait until user clicks OK. Since form is shown and until user clicks "OK" I need to pause this thread.
myThread.Suspend() dont work:
Warning 2 'System.Threading.Thread.Suspend()' is obsolete: 'Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202'
How can I make Suspend() work ... or is there any another way to do it?
|
|
|
|
|
First, you cannot start a form from another thread. Create and use forms & controls ONLY on the UI thread. This is a golden rule of Windows UI programming.
If you need to show a form, show it on the UI thread. If a background thread needs to wait, have it watch a variable and Sleep(0) in a while loop while that variable is true:
while(myFormIsVisible)
{
Thread.Sleep(0);
}
I might be misunderstanding what your problem is. If you could better explain what you're trying to do, we might be able to help you further.
|
|
|
|
|
Judah Himango wrote: First, you cannot start a form from another thread.
That is a common misconception. The actual rule is "You can only access and manipulate UI/Form elements from the thread they were created on."
It's perfectly legal to create forms on separate threads as long as you obey the above rule.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/
|
|
|
|
|
Yes, you're right, my mistake. I just never use controls from background threads period, so I've blurred the distiction I guess. My mistake.
|
|
|
|
|
First of all, thank You very much for your answer. I've understood how to pause a thread, but now I don't understand how to show a form (before: form showed only after thread was finished).
I have a form "mainForm" with button. When I click button: thread "fP" starts.
Button event:
private void fileProccessing_Click(object obj, EventArgs ea)
{
fP = new Thread(new ThreadStart(fProc));
fP.Start();
}
Thread:
public void fProc()
{
editForm edtFrm = new editForm();
...someText...
if( ... )
{
edtFrm.Show();
edtFrm.cmbBox.DataSource = fieldsBaseD;
while (edtFrm.Visible == true)
{
Thread.Sleep(0);
}
}
}
And in another file I have second form "editForm" (which I want to show)
class editForm : Form
{
public ComboBox cmbBox;
private Button buttonOk;
public Label label1;
public editForm()
{
InitializeComponent();
}
....
}
but thats dont work... it tries to show a form and programm becomes to not responding
|
|
|
|
|
Try changing fProc to the following.
<br />
public void fProc(){<br />
<br />
editForm edtFrm = new editForm();
...someText...<br />
if( ... )<br />
{<br />
editForm.cmbBox.DataSource = fieldsBaseD;
Application.Run(editForm);<br />
}<br />
}<br />
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/
|
|
|
|
|
It helped. Thank you very much!
|
|
|
|
|
hey. im kinnda new to the programming world. well i just want to know how do i start programming in C#, i mean like any good book to rec. or something that actually eexplains the basic. thats all i need the basic. i dont really hhave any strong backkground. i done vb6 before but i suucked at it and some pascal too. thx.
|
|
|
|
|
Jesse Liberty's "Programming C#" might be what you're looking for. It spends a lot of time explaining the basics before moving on to advanced topics. Its what I used to learn C#(although I did already have skill in C++).
|
|
|
|
|
if i were in your position, i would recommend starting with a bit of programming theory. I dont know how familiar you are with the Object Oriented Paradigm but i would definatley start on literature that is indepenedent of a programming language. The internet is GOLD for literature out there. Wikipedia.com has a lot about Object Oriented Analysis and Design, and Design Patterns. Here is my suggestion:
1. Learn Object Oriented Analysis and Design and what it all means (google it and read up on it at Wikipedia...there is so much out there and i hope you enjoy the theories presented)
2. Learn about design patterns: these are frequently reoccuring problems that show up in many programming projects (there are apporoximatly 30 or so patterns). This will provide a good base for solving problems.
3. Search of "best programming practices in C#", this will get you used to the language its, syntax and what is considered elegent coding.
4. Start learning the .Net framework (www.microsoft.com and F1), there are a lot of examples at microsoft.com, they have 30 examples that show some basic GUI interactions and many other basics that will prove to be useful
5. If you are rusty on looping, branching, function calling and some simple coding logic then start with console based projects. And play around with it.
The key to becoming a good programmer is to have a good understanding of software design. With a good base (steps 1-3), any programming language will come easy to you. If you just want to jump right in then i would check out the c# examples on Microsofts website. They will definately give you a big jump start into c#.
good luck
|
|
|
|
|
if I have a statement like ..
myArrayList.Add ( new MyStructure );
does the structure get allocated on the heap or the stack? Seems like it should be the heap, but most of what I have read says structures are always allocated on the stack. I saw where if you assigned the results of the new to a local variable that it would be on the stack - that I can understand; but what about the case above? The stack just doesn't make sense to me, but I wanted to confirm.
Thanks,
Brett
|
|
|
|
|
All structures get stored on the stack. All classes get stored on the heap. This means MyStructure will get stored on the stack since it is a structure, not a class.
However, if you look at ArrayList.Add method, you'll notice it takes a System.Object as a paramter. Since System.Object is a class, there will be an expensive, slow operation known as boxing will occur: a new object will be created on the heap and will copy the MyStructure from the stack onto the heap.
And when you retrieve your MyStructure out of myArrayList, you'll need to cast it back to MyStructure, which will induce unboxing which is also overhead.
Boxing is slow, causes heap allocations, and eventually forces costly garbage collections. That is why you need a list that can hold MyStructure objects without boxing them. If you're using .NET 2.0, you can go
System.Collections.Generic.List<MyStructure> list = new List<MyStructure>();
list.Add(new MyStructure());
This will allow you to have a very fast & efficient list for storing MyStructure objects without any boxing.
|
|
|
|
|
Judah Himango wrote: System.Collections.Generic.List<mystructure> list = new List<mystructure>();
list.Add(new MyStructure());
This also comes with a cost (almost always small). Generic classes like any other must go through a JIT Compile the first time they are used/accessed. As you can imagine, the JIT'd assembly for all of the generic classes and methods for objects is the same since you are just manipulating a pointer. So as long as you are using reference types as your generic paramaters then you only suffer the JIT penalty once and also one memory overhead hit.
Structs are a bit different though since they are allocated on the stack and have varying range in sizes. The JIT'er is forced to JIT separate code for each different set of generic parameters that includes at least one ValueType. This means an extra JIT and the associated memory that comes with the JIT.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/
|
|
|
|
|
Yep. Still quite a bit better than constantly boxing/unboxing, I'd say. Not to mention the benefit of type safety is a huge boon IMO.
|
|
|
|
|
Judah Himango wrote: Not to mention the benefit of type safety is a huge boon IMO
I love type safety!
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/
|
|
|
|
|
I see. Thanks for the explanation Judah. I switched it to a class and it seems to be working ok. The function Marshal.StructureToPtr seems to still work with the class object. I've been using the windows journaling to synthesize mouse and keyboard stuff. Defining the EVENTSTRUCT as a class seems to work ok.
public class Win32
{
[StructLayout(LayoutKind.Sequential)]
public class EVENTSTRUCT
{
public uint message;
public uint paramL;
public uint paramH;
public uint time;
public IntPtr hwnd;
public EVENTSTRUCT (uint message, uint paramL, uint paramH, uint time, IntPtr hwnd)
{
this.message = message;
this.paramL = paramL;
this.paramH = paramH;
this.time = time;
this.hwnd = hwnd;
}
}
|
|
|
|
|
Hi there.
I made a form with some Label controls on and lines and stuff. I have managed to make the computer print it. However, I would now like to add some code that will allow me to print out a second page with stuff. There is where my problem lies The following code I added right after coding the very last thing that gets printed on the first page so the following is supposed to be printed on the second page:
e.HasMorePages = true;
Label svar1 = new Label();
svar1.Font = new Font("Times Roman", 12);
double result = double.NaN;
result = double.Parse(tnr1.Text) + double.Parse(tnr2.Text);
svar1.Text = result.ToString();
f.DrawString(svar1.Text, svar1.Font, new SolidBrush(svar1.ForeColor),
65, 1650);
e.HasMorePages = false;
This however yields nothing, only the first page gets printed. Can someone please help me? What am I missing?
Best regards,
FJ
|
|
|
|
|
|
Hi all,
Well I am trying to learn C# so I made up a poject for myself. It's a small program that makes a playlist so it can pass it to other applications. Well my problem is that I keep getting a Access To Path Denied. Here is a picture of my error:
http://www.streamload.com/half_ex/help.jpg
I have tried tweaking the .Net 1.1 Framework Configuration. Had no luck there and I read somewhere that you can go ahead and request the permission through code also. Well my main question is shouldn't I be able to write to disk since there is no security on the file I try to write to and also I am logged in as an administrator account? And also how do I go about having permission to write, read to my hard drive? Help Plz...Thanks
Lee
|
|
|
|
|
Can you post the full text of the exception? Also can you post the full text of the Build() method?
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/
|
|
|
|
|
Here is the Build()
public void Build()
{
//string to find the location of .exe
string directory = WhereAmI();
//name pulled from user and to name the playlist then add .mply extension
NAME = NAME + ".mply";
//set lentgh the of the strong minus 20
int temp = directory.Length -20;
//then cut the last twenty characters
NAME = directory.Remove(temp,20);
//then sets the directory to another vaiable
string FILE_NAME = NAME;
//create a streamwrite
StreamWriter writer = new StreamWriter(FILE_NAME);
//writes a line to the file
writer.WriteLine("This is a test again");
//close stream writer
writer.Close();
}
Then the error I get that is thrown is:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the path "C:\All Data\VS 2003 Projects\Tiny Mp3 Player\bin\Debug" is denied.
Thanks
Just ask if you need anything else.
Just Trying To Make It Through The Day!
|
|
|
|
|
Hey I know what I was doing wrong. I had to many variables around floating so I simplified it. What was happening was I was trying to write text to a directory. Not a file. Thanks for the help Jared!
Just Trying To Make It Through The Day!
|
|
|
|