|
I have 2 List: customer list, supplier list
I have designed frmCus for customer list
I have designed frmSup for suppler list
I have a textbox: txta
I have a button : but1
When I click but1, if txta = "frmCus" then frmCus.show
else if txta = "frmSup" then frmSup.show
Can you help me ?
Thanks
|
|
|
|
|
When handling the button click, do you already have instances of frmCus and frmSup? If you do, you can simply do
Form form = null;
if (txta.Text == "frmCus")
form = frmCus;
else if (txta.Text = "frmSup")
form = frmSup;
form.Show();
If not, you'd have to resort to using reflection to create instances of frmCus and frmSup, using Activator.CreateInstance .
Form form = null;
if (txta.Text == "frmCus" || txta.Text = "frmSup")
form = (Form)Activator.CreateInstance(null, txta.Text);
form.Show();
This would create instances of frmCus and frmSup everytime you click the button, which may or may not be what you want. If you want to avoid creating instances everytime, you can have member variables in the class to refer to the instances created and then check for null before creating the instance.
|
|
|
|
|
Hi
I have problem with this code.
when a soloution have a more than project its not work
this code works only for main project. and for another project the value of formType is null.
please help me.
|
|
|
|
|
i create a class and generated random numbers using
texture = TextureStorageComposer.Objects[random.Next(0, 4)];
and then create 10 instances of that class
now the wired thing is that it gives same value to each instance when i run it
it gives different values when i step through it
i think this is because random is a time based function and all this processing is happening in less than 1ms (so all instances have same time for computer)
can you please help me in workaround
|
|
|
|
|
Are you creating 10 instances of System.Random or are you reusing the same instance and calling Next ? You should be getting repeated numbers only if you create multiple instances of the class very quickly. Did you try creating a single instance and repeatedly calling Next instead?
Alternatively, you could try using the RandomNumberGenerator[^] class.
|
|
|
|
|
Hi,
Im just wondering, how do you write the equals operator in C#.
Im slightly confused about the syntax.
For example in C++ for a vector :
<br />
class vector{<br />
private:<br />
float m_x;<br />
float m_y;<br />
float m_z;<br />
<br />
public:<br />
vector(x,y,z): m_x(x),m_y(y),m_z(z);<br />
vector(): m_x(0),m_y(0),m_z(0);<br />
~vector();<br />
<br />
bool operator==(Vector v)<br />
{<br />
if (this == v)<br />
return true;<br />
else<br />
return (m_x == v.m_x && v.m_y && v.m_z);<br />
}<br />
}<br />
I know its got something to do the Equals Function and Reference Equals Method. How do you test to see if its the same instance?
Many Thanks in advance
Tom
|
|
|
|
|
|
Thanks Nick,
Much Appreciated.
Its just that in C++ you would use the this statement and check against the type on the right.
I was just wondering if ReferenceEquals and Equals use the same kind of technique deep down in the CLR thats all.
But as for implementing it, you've hit the nail on the head.
Many Thanks
|
|
|
|
|
|
hi
it is my Code :
DataTable dt = new DataTable();foreach (DataGridViewRow _gridViewRow in dataGridView1.Rows)
{
if (_gridViewRow.Cells[0].Value != null && _gridViewRow.Cells[0].Value.ToString() == "True")
dt.ImportRow(ds_zamin1.Khaneh_1.Rows[_gridViewRow.Index]);
}
this.dataGridView1.DataSource = dt; // dt is global viriable
but when i execute this method,nothing occured,only myDatagridView show some blank row(s).
how to solve problem ?
|
|
|
|
|
Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued?
i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items.
I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue.
Is this possible? And how could i do it?
Cheers guys
Tristan Rhodes
|
|
|
|
|
Interesting quesiton. I don't believe setting the thread priority has anything to do with the acceesing the lock, I thought it was a FIFO construct. Never really thought about type of situation though.
only two letters away from being an asset
|
|
|
|
|
|
|
AFAIK they removed the original form border and created custom stuff for their form
|
|
|
|
|
Yep, but HOW...cause since the design mode I can't do it, the form properties don't allow me to do this things.
|
|
|
|
|
Set FormBorderStyle to none and draw the window yourself. Search for overriding WndProc and handling NC_HITTEST to make Window handle resizing/moving on a self-drawn form.
|
|
|
|
|
Hi,
Please help me …. I got a weird problem. I finished my project, everything was working fine. Recently my Win XP was updated by automatic update and I am not sure if my problem is related to this new update or not.
My problem:
In my win application, I have some MDI windows. Now, when I was running my application, I found that, some MDI Children is not being loaded, and 1 or 2 MDI children are being loaded. I could not understand why! So In my Visual Studio 2005 Professional, I clicked the Forms which were not being loaded. And I discovered that, I can’t open those windows anymore in the design mode. Nor even I can’t open them in the Code mode. Very frustrating! And Strange that, Some times when I tried to view the window in Design mode (VS 2005 Professional) instead of showing my Window Design, I used to get an Error Screen, some message was like “ License Manager …locked.. canot change the lock status….” Etc…etc…. I have no idea, from where this License Manager come….. Can you please help me..
Thanks and regards//…
|
|
|
|
|
The task is to do something when my USB-device gets plugged or removed.
I already created some working code using an (invisible) NativeWindow that processes the WM_DEVICECHANGE messages. This has already been covered in several articles.
My Windows.Forms Testapp works fine. The WM_DEVICECHANGE messages are trapped by my window and i can react to it.
But could I do the same thing from a console-app??
I am able to create and register my invisible Window for notifications but the
NativeWindow.Wndproc() method I have override never gets called.
I guess I am missing something very basic here!
Any hints in every language (not tied to c#, I will find my way around) are very Welcome.
Thanks for reading
Eberhard Fahle
|
|
|
|
|
I am just guessing that you might need a message pump, like you get when you call Application.Run in a Winforms project.
If you must use Console rather than Windows forms project type then you can add an Application.Run statement into your program (once you add the relevant namespaces) and then you will receive messages.
Just a hunch...
|
|
|
|
|
Hi All,
My multithreaded app seems a little slow, and i'm not really sure where the cpu time is going. I suspect that i'm wasting time waiting for locks etc, and could probably structure the code a little better.
but are there are tools that help you analyse what threads are doing?
- how much cpu time each thread is using
- how much time each thread spends blocking on a lock object
etc.
trying to diagnose the issues without better tools is going to be hard.
Thanks
Jon
|
|
|
|
|
i have the same problem and currently downloading intel Vtune evaluation copy
lets see if it helps
|
|
|
|
|
Hello, is it (Vtune) really useful for C# code ? I di not see any feature in VTUNE so that i Know exactly which code segment is taking more CPU time ? I know VTUNE support C language, but I did not see any C# supports. When I tried to see the code, VTUNE exposed me the ASSEMBLY code for the given EXE file. Obviously seeing Assembly code will not make any sense for me to debug High Level C# code, aint i right ?
would you Please let me know if I can make it useful for c# ?
|
|
|
|
|
bashiwala wrote: Obviously seeing Assembly code will not make any sense for me to debug High Level C# code
Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
its working now its integrated in vs ide and it shows the code and lots of other information i need to study more what it shows but its working perfectly with c# however it require more ram and processor speed so it will be better to increase virtual memory before hand
to know how it works please read the tutorial attached with VTune demo it is of about one hour
|
|
|
|