|
Interesting. Then I withdraw my complaint.
only two letters away from being an asset
|
|
|
|
|
Do you mean C, C++, or C# ? This is the C# forum.
Also, I have no idea what the 'space elevator' problem is, but you need to post your code before anyone is going to do your homework for you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I hosted grid in a usercontrol and the usercontrol is hosted in Tab, something like
TabPage->UserControl->Grid
When i come out of the Grid. Grid's Leave event is not firing.
Any Ideas?
Thanks
kumar
|
|
|
|
|
It won't fire on your Form? Of course not. It won't go any further that firing inside your UserControl. If you want the event to be visible outside your UserControl, you'll have to handle the event in the UserControl and reraise an a new event from your UserControl code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
but Grid's Leave event is firing when i am moving from one Tabpage to another tabpage.
To each tab page's control collection a usercontrol is getting added at run-time. And usercontrol adds Grid at runtime to its control collection.
|
|
|
|
|
Hi guys,
Requesting kindly for your help.
I have a 3 listboxes in my form, my first listbox allows multiple selection and second allows just one. I am trying to do the following: Move to the third box:
Selection 1 from box 1 + Selection 1 from box 2 to box 3
selection 2 from box 1 + selection 1 from box 2 to box 3
continue until all selections from box 1 are moved.
I can't figure out how to clearselected in box one and increment to the next selection in box 1.
Please help!
sasa
|
|
|
|
|
Hello, I'm using C# 2.0 generics in an application I'm writing and I have a question about copying one list to another.
The List<> generic doesn't seem to have a deep copy method. It has CopyTo() but this copies to an array, not to a List<>.
Suppose I have a large list of objects:
main()
{
List<MyClass> original = new List<MyClass>();
// add 10000 MyClass objects to original...
// ...<snip>...
List<MyClass> backup = new List<MyClass>();
ShallowCopy<MyClass>(original, backup);
}
static void ShallowCopy<T>(List<T> source, List<T> dest)
{
dest.Clear();
foreach(T t in source)
{
dest.Add(t);
}
}
OK, this gives me a shallow copy, but what if I want a deep copy? It doesn't look like there's a deep copy built into generics... or what am I missing?
Thanks,
Jeff
-- modified at 17:27 Wednesday 7th February, 2007
|
|
|
|
|
I know someone here asked exactly the same thing about a combo box but i tried and it didn't work, i have a treeview that contains process names and i want to check if a process exists there before i add it, i tried something like this and it didn't work:
<br />
Process[] a = Process.GetProcesses();<br />
for (int i = 0; i < a.Length; i++)<br />
{<br />
TreeNode mb = new TreeNode(a[i].ProcessName);<br />
if (!(treeView1.Nodes.Contains(mb)))<br />
treeView1.Nodes.Add(a[i].ProcessName);<br />
}<br />
Any suggestions?
|
|
|
|
|
ummm... you create a "new" TreeNode and then ask the Tree if it contains it? Why do think that would work?
led mike
|
|
|
|
|
Oh...well...is there a way to check if a string exists in a treeview? (that's what i thought i was doing o_O), as in the node names?
|
|
|
|
|
The simplest is to iterate through the nodes comparing Texts.
Better is to put the process Id in the Tag field and compare those.
On the other hand, if you also need to remove Nodes from the TreeView when the process ends how do you do that? What I do in cases like that is simply Clear the TreeView and add all the current Nodes.
|
|
|
|
|
I'm using a timer which checks it but there's the problem, i need to check if a process exists before adding it to the treeview...and can anyone give an example since i have very little experience with treeviews.
And about the response about not checking the child nodes - that's because there are none, only roots.
|
|
|
|
|
Imho, the most time (not space) efficient way to do this is to maintain a temporary parallel list of entries which you can check against (using .Contains() ) before attempting to add an entry ito the treeview.
/ravi
|
|
|
|
|
What you tried fails because treeView1.Nodes includes only the root nodes of the treeview. i.e. not the children of the root nodes.
One way is to recursively check for the item:
if (!NodePresent(treeView1.Nodes, mb))
{
//do your stuff
}
private bool NodePresent(TreeNodeCollection Nodes, TreeNode node)
{
if (Nodes.Contains(node))
return true;
foreach (Treenode treeNode in Nodes)
{
if(IsFolder(treeNode) && NodePresent(treeNode.Nodes, node))
return true;
}
return false;
}
private bool IsFolder(TreeNode node)
{
// Use the image index, node.Nodes.Count or a method of your choosing to determine whether child nodes may be present
}
Good Luck!
|
|
|
|
|
Hello everyone,
I have created a window application using Visual C#. I wish to set the window property as the width and hight are resized together rather than indivitually. What I mean by that is "I wish to width/hight" ratio stays same when a user try to change the width or hight.
Could you guys tell me how I can do that please?
Thank you for your time,
Khoramdin
|
|
|
|
|
Uhh, it's not a realy complicated solution but how about making two integers which contain the start window size and then after each resize (resize event) do like:
int SizeThingy = CurrentWidth - StartWidth;
CurrentHeight += SizeThingy;
and make the height CurrentHeight
the best solution i could think of (and the simplest one).
|
|
|
|
|
Save your form's aspect ratio (.Width /.Height , stored as a double ) in your form's Load event. Then in the SizeChanged event, compute and set the new height and width. If the SizeChanged event happens to be raised recursively, use a flag to ignore the event generated when your code modifies the form's dimensions.
/ravi
|
|
|
|
|
I can't seems to find enough sources to decode an attachment. I get the following line.
it tells me the name of the image and what type of content is it.
------=_NextPart_000_0010_01C74AC1.03E2B080
Content-Type: image/gif;
name="mapping.gif"
Content-ID: <001301c74ac1$03e2b080$0124cc3c@VALERIA>
Content-Transfer-Encoding: base64
Where i'm having problem is on the attachment that will look like this, how can i convert that?
<br />
<br />
<br />
R0lGODlhygHoAIcAAAAAAP/5lm/wAAmTOIIv8AAGb
4xgYGE1NTYKCgre3t+zs7CEhIVZWVouLi8DAwPX19SoqKl9fX5SUlMnJyf7+/jMzM2hoaJ2d<br />
<br />
------=_NextPart_000_0010_01C74AC1.03E2B080--<br />
<br />
|
|
|
|
|
As the content information tells you, it's base64 encoded. Take a look at the Convert.FromBase64String method.
---
single minded; short sighted; long gone;
|
|
|
|
|
thanks for the reply Guffa, i did a search on the Convert.FromBase64String and found a good source of code in http://msdn2.microsoft.com/en-us/library/system.convert.frombase64string(VS.71).aspx[^]
however when I run the following code I get the error Base 64 string length is not 4 or is not an even multiple of 4.
Did I miss something or Am I doing something wrong?
<br />
byte[] binaryData;<br />
try <br />
{<br />
binaryData = System.Convert.FromBase64String(attach);<br />
}<br />
catch (System.ArgumentNullException) <br />
{<br />
MessageBox.Show("Base 64 string is null.");<br />
return;<br />
}<br />
catch (System.FormatException) <br />
{<br />
MessageBox.Show("Base 64 string length is not " +<br />
"4 or is not an even multiple of 4." );<br />
return;<br />
}<br />
<br />
System.IO.FileStream outFile;<br />
try <br />
{<br />
outFile = new System.IO.FileStream(Application.StartupPath+"\\josetest.gif",<br />
System.IO.FileMode.Create,<br />
System.IO.FileAccess.Write);<br />
outFile.Write(binaryData, 0, binaryData.Length);<br />
outFile.Close();<br />
}<br />
catch (System.Exception exp) <br />
{<br />
System.Console.WriteLine("{0}", exp.Message);<br />
}<br />
|
|
|
|
|
What does the attach string contain? If you just ripped it from the mail, you have to remove the line breaks from it, so that it only contains the base64 data.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone:
I have a TxtBox with vertibal bar enable and Button. When user click on Button and and browse to select any file, that file would get store on that txtbox.
I dont know how to started. Could someone please provide some sample code that I could work with?
Thanks,
Eyungwa
|
|
|
|
|
Did you not read my reply[^] to your earlier identical post?
/ravi
|
|
|
|
|
To let the user select a file take a look at the FileOpenDialog . An example how to use it is provided by its MSDN topic. How to load the file into a textbox was already answered in your other thread.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you Ravi,
tb_Text.Text = File.ReadAllText("C:\\Test");
I got this error saying " The name 'File' doesn't exist in the current context"
I like to have txtbox display all the files from C:\Test\ folder and being able to add any file onto that fold as well.
-- modified at 16:51 Wednesday 7th February, 2007
|
|
|
|