|
ya, that's the main problem, it's will not only confuse the user but also make coding harder. and most important thing is it's not possible to go with the assumption that every text will be unique. like if i build a library system(for an instance) i may have menu like --> Book > Add ; Member > Add
now on click of both add i get that "Add", and my program can't understand which "Add' has been called? Can you give any solution?
Beside this i was trying to pass the name through variable, i've tried that in sevaral way but none worked out. if i want to pass the name through a string/array how can i do that? like :
MenuItem strMenu = new MenuItem(); //considering strMenu has some value as the name of the menu
though this code is wrong, i'v just written it to explain my query.
And Thanks for your reply
|
|
|
|
|
You could save the MenuItem s in an array:
MenuItem[] menuItems = new MenuItem[arrValue.Length];
for(int i = 0; i < arrValue.Length; i++)
{
menuItems[i] = mnuMod.MenuItems.Add(arrValue[i], new EventHandler(mnuModMenu_Click));
}
menuItems[i].MenuItems.Add("First submenu's first item", new EventHandler(...)); Just remember that if you use the same event handler, you'll have to identify in it which menu item was selected, and if you didn't save all the MenuItem references, you'll have to do it by text.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hi All,
I am creating a class with a Hash Table as one of its objects. I am taking Hash Table as one of its members because, i need a key value pair there.
After creating the Object, i need to serializing the object into an XML file.
Obviously, it will throw an error, as hash table cannot be serialized.
How will be able to serialize such a class then. I need the hash table inside this class object only.
Anupam Mazumdar
|
|
|
|
|
|
I try to implement drag and drop in .NET FrameWork 2.0. The code below works fine. You have to drag one node onto the other. The problem is that the exception is lost. When I call the failing function via the button everything is fine, the exception comes as expected. But when I do it from drag and drop nothing happens, the exception disappears as if handled by an external code in the FrameWork. Am I doing something wrong?
The form contains only a treeview with two nodes, and a button:
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace DragAndDropTest<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private TreeNode previousTarget;<br />
<br />
private void FunctionThatFailes()<br />
{<br />
throw new ApplicationException("Something is wrong");<br />
}<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)<br />
{<br />
treeView1.DoDragDrop(<br />
treeView1.SelectedNode, DragDropEffects.Move);<br />
}<br />
<br />
private void treeView1_DragDrop(object sender, DragEventArgs e)<br />
{<br />
TreeNode source = e.Data.GetData(typeof(TreeNode)) as TreeNode;<br />
TreeNode target = previousTarget;<br />
ResetPreviousTarget();<br />
FunctionThatFailes();<br />
target.Text += source.Text;<br />
}<br />
<br />
private void ResetPreviousTarget()<br />
{<br />
if (previousTarget != null) {<br />
previousTarget.ForeColor = SystemColors.WindowText;<br />
previousTarget.BackColor = SystemColors.Window;<br />
previousTarget = null;<br />
}<br />
}<br />
<br />
private void treeView1_DragOver(object sender, DragEventArgs e)<br />
{<br />
ResetPreviousTarget();<br />
<br />
if (e.Data.GetData(typeof(TreeNode)) != treeView1.SelectedNode) {<br />
e.Effect = DragDropEffects.None;<br />
return;<br />
}<br />
<br />
TreeNode target = treeView1.GetNodeAt(<br />
treeView1.PointToClient(Control.MousePosition));<br />
if (target == null || target == treeView1.SelectedNode) {<br />
e.Effect = DragDropEffects.None;<br />
return;<br />
}<br />
<br />
e.Effect = DragDropEffects.Move;<br />
<br />
if (target == previousTarget) {<br />
return;<br />
}<br />
<br />
previousTarget = target;<br />
<br />
target.ForeColor = SystemColors.InactiveCaptionText;<br />
target.BackColor = SystemColors.InactiveCaption;<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
treeView1.AllowDrop = true;<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
FunctionThatFailes();<br />
}<br />
}<br />
}
Gyozo Gaspar
Software Developer
|
|
|
|
|
Just a guess, but the .NET framework may contain error handling for drag and drop to prevent anything horrible from occuring; for if an exception occurred during drag and drop, you would end up corrupting cross-process OLE data transfers; the source application may think you're still trying to perform a drag and drop even though an error has occurred and the drag is not continuing.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Moral Muscle
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
How can I save .doc or .pdf file in sql database ???
Regards...
|
|
|
|
|
You can save them as the SQL Binary type if the data is less than 8000 bytes (8K). If you need to store files larger than 8kB, you could save them using the SQL Image type (which simply stores an array of bytes of length up to 2 billior or so). For more information on SQL datatypes, see MSDN's Sql data type table[^].
Once you've stored your pdf or doc files as bytes, you can then get them out of the database, write the bytes to a file, rename the file with the correct extension, and you're good to go.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Moral Muscle
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Hi all. How can I get a connectionString in web.config after I has been registed RemoteObject on IIS with .Net Remoting? Please help me!!!!!!!!!!!!!!!
-- modified at 8:58 Friday 10th March, 2006
|
|
|
|
|
Im new to using Xml with C#. I have been hacking around at one section for a day now and can't get it to work at all. Rather than confuse you with my shambles code, I will jsut explain the concept. Im also slightly confussed, or misslead with my understanding of the type deffinitions, and their methods for subtrees.
<br />
XML...<br />
<Root><br />
<MajorKey att="MAJattribute1"><br />
<MinorKey att="MINattribute1"><br />
<Value>value1</Value><br />
</MinorKey><br />
<MinorKey att="MINattribute2"><br />
<Value>value2</value><br />
</MinorKey><br />
</MajorKey><br />
<MajorKey att="MAJattribute2"><br />
<MinorKey att="MINattribute3"><br />
<Value>value3</Value><br />
</MinorKey><br />
<MinorKey att="MINattribute4"><br />
<Value>value4</value><br />
</MinorKey><br />
</MajorKey><br />
</Root><br />
Im having trouble getting it to create a nodelist to children underneath a node based on it's att (attribute) value. Also, I want to extract that attribute value into a string so "MAJattribute1" would gointo a string inside the loop for that node treversal.
Any help, or suggestions.
I have spent hours and hours reading, and cant seem to find anything to pinpoint this...only ever creating attributes indide a single node, not looping through based on the attribute value.
IM GETTING STRESSED
Regards
njc
|
|
|
|
|
Edit your post, check Ignore HTML tags in this message (good for code snippets) and then we'll be able to see what you're talking about.
The w3schools site has good XPath tutorials, but I believe @ is used to indicate that you're specifying an attribute value.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Im in a situation where my set up project should install two applications ina quite mode. first i should install .net sdk and then my .net application without by a single click. Is it possible. Please help me to solve this problem.
Regards
Mukilan.P.S
|
|
|
|
|
I guess you mean the .net framework and not the sdk.
If so, take a look at 1 of these articles:
Visual Studio 2005
http://msdn.microsoft.com/msdnmag/issues/04/10/Bootstrapper/
Visual Studio 2003
http://msdn.microsoft.com/vstudio/downloads/tools/bootstrapper/
I'm in the high-fidelity first class traveling set.
And I think I need a Lear jet.
|
|
|
|
|
thank you very much spif,
I dont have much experience in Installers. If you are able to guide me clearly about how to install SDK in a quite mode wihtout any windows flickering will be helpful for me.
Anyway thank you very much for your immediate reponse.
Mukilan.P.S
|
|
|
|
|
You can use many installers, but my favourite is Inno Setup. It's free and even for commercial use.
If you're not familiar with installers, you can download also IS Tool, which creates your setup project using step wizard.
You'll have two items in the "Files" category there. The one is a directory (or just executable) of your app, and the second is the Framework SDK (marked as decompressed into {tmp} (temporary) directory, so its installer will be deleted after whole installation).
Now add this file in the "Install Run" category, so that it will be runned after installation of your app. If you want to install it before your application, you have to create a setup component.
To make the installation quiet, the SDK installer have to be runned with some parameter ("/q" I think).
Hope this helps.
|
|
|
|
|
Thank you very much Itinka,
I dont have much experience in Installers. If you are able to guide me clearly about how to install SDK with the parameter like "/q" will be helpful for me.
Anyway thank you very much for your immediate reponse.
Regards
Mukilan.P.S
|
|
|
|
|
Dear Itinka,
How to pass the command line arguement switches which supports the install.exe. From where to pass this command line arguements from the setup project. Only one window should be there which is a progress bar and all other installations should be done at the background without any clicks or user interaction. First it should install the .Net Framework 2.0, which will reflect in the progress bar, then it should start automatically the application and it should ececute and installed in the same manner by a single click. All the changes should reflect in the progress bar.
Can u please guide me on this requirement.
Regards
Mukilan.P.S
|
|
|
|
|
How can I check whether a file is locked? My code for now is this:
int retrycount = 0;
bool copied=false;
while (!copied)
{
try
{
System.Threading.Thread.Sleep(1000);
File.Copy(filenameSource, filenameDestination, true);
copied = true;
}
catch
{
retrycount++;
System.Threading.Thread.Sleep(1000);
if (retrycount > 100)
{
break;
}
}
}
Is there a solution without catching exceptions? And one more thing - if I comment out the first Sleep, the file will be copied, but blank??? I should mention that the destination filename is on a remote computer. That doesn't occur if the destination filename is on local computer.
|
|
|
|
|
Hi All.
I want to write some small application that check evry X second if there are some messages in MSMQ.
1. I dont find any example how to do it ...
2. What is the class that i need to use to get MSMQ control ?
Thanks for any help.
-- modified at 4:59 Friday 10th March, 2006
|
|
|
|
|
Use a background thread that constantly checks a queue. Nothing magical or elaborate.
If you need help getting started with MSMQ, there are a few good articles on CP, such as this one[^].
|
|
|
|
|
Hi,
I am a music technologist and fairly new to c#. I am trying to find a way of creating a simple sine wave oscillator with a frequency control - can anyone help? Also does anybody have any advice on creating custom Max/MSP objects?
Cheers.
Subdiffusion - www.subdiffusion.com
|
|
|
|
|
I'm trying to make a control paint itself to a bitmap and save it.
I'm trying to do this by making the control paint itself to my graphics object and not by screen capturing and coping.
I have had a success with button and label for example. I override the class (ex. button) and made a SaveGraphics method which initialized a bitmap and called the OnPaint method with the bitmap's graphics object.
I've had less success with a TextBox or UserControl. In a UserControl, I can call each control with InvokePaint but that still does not work for a TextBox.
In overriding a TextBox, calling OnPaint method does not render the text.
Anyone have an idea on how to save a TextBox's graphics content to a Bitmap?
-- modified at 4:13 Friday 10th March, 2006
|
|
|
|
|
Question asked,
Answer given...
I looked a bit and found those here:
http://www.codeproject.com/cs/miscctrl/alphablendtextbox.asp
http://www.thecodeproject.com/cs/miscctrl/AlphaBlendedTextControls.asp
If I'l succeed I will post another answer.
|
|
|
|
|
Hey guys, I thought I'd start a separate post for this message since it's really a different topic but for the same program. Anyway, what i want to do is get the clipboard using Clipboard.GetDataObject() and then store that data for later use (even after the current clipboard has long since changed). then i'd like to use Clipboard.SetDataObject(mySavedClipboard); to reset the clipboard with my saved one. It seems like whenever i restore the old clipboard it just ends up being blank when i paste.
I've also tried to create a new IDataObject and loop through the stored formats and use SetData to copy over all the data contained in the original clipboard. this somewhat works but it definitely doesn't get everything. For example, if i copy just plain text from notepad, it will work and get restored, but if i try to copy part of a webpage or something from a rich text box, it won't copy over and will end up being and empty clipboard.
Anyone have any ideas?
Any help would be really appreciated.
Thanks in advance
-Jeremy
|
|
|
|
|
I've come accross a strange problem with sendkeys. basically what i have is an app that monitors the clipboard by watching for the WM_DRAWCLIPBOARD and then retreives it when it comes up. My problem only comes up when i've selected part of a webpage in Internet Explorer and then use sendkeys.send or sendkeys.sendwait in my program to force a copy to the clipboard... when I do this, the WM_DRAWCLIPBOARD message never shows up in my program. The really funny part of it is that if i do the exact same thing and physically press the keys, i get the message and everything is great. I'm thinking something with sendkeys, has to be blocking the message somehow..
right now my program is basically just a timer that fires a sendkeys.send("^C") every second. so when i switch to another app and select text, it can copy it when the timer fires.
Out of desperation i even created a thread and fired off the send keys in there but to no avail. is there a way to start a new thread that is completely seperate from the program itself?
|
|
|
|