I'm a C# newbie. How can I insert a new line into a multi-line TextBox field? I've tried '\n' but instead of inserting a new line, it displays a strange character. Also, I want a particular method to execute when a user presses 'Enter' key after typing something in TextBox. Please help!
Not necessarily in the TextBox (which encapsulates the Edit common control). To dislay new lines in a TextBox, the Multiline (inheritted from TextBoxBase) needs to be set to true, as well as the AcceptsReturn property.
See SqlCommand in MSDN or search for it in this site or Google to see how to run commands and SP in SqlServer from your C# application. When I test @@version and that SP the second one return informations for me , don't know wht so I recommed second way to you.
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
I have written a C# Windows form with a panel on top of it. As the program runs, a directory is opened and for each image file in the directory a picturebox is dynamically created and loaded onto the panel. As I create each picture box, I give it a Click event handler (the same function for each picture box) where I want to bring up a SaveFileDialog. This all works fine, however, I cannot figure out how to get to the individual picture box that was clicked on so that I can access the image it contains during the event. Can anyone help?
That was the solution I needed.
I thought it had something to do with the sender object, I had even tried casting it as a PictureBox but kept getting compile-time errors. I never even thought of making a new PictureBox object and assigning it. Thanks again.
DustinMiles wrote: I never even thought of making a new PictureBox object and assigning it
You are not actually making a new picture box object with the previous code. What is happening is that you are creating a reference to the picture box. The variable is a reference to, not a copy of, the PictureBox.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
If I rememebr correctly, the TreeView control doesn't support a background image, nor does it support a transparent background. You'd have to draw the control yourself to get an image to show through it or behind the actual tree that is drawn. I can't seem to find any examples of it, but you might want to look into overriding WndProc.
This could be very ugly, if even possible. The Tree-View common control that the TreeView class encapsulates doesn't even support this. The poster's best bet is handling the WM_ERASEBKGND but I'd be willing to bet this wouldn't work.
It depends on what kind of 2d terrain you have. If your terrain is a bump map, like what you see on a globe, where different colors or intensities correspond to different heights, then all you have to do is set for each pixel in your 2d terrain a pixel of the same height in your 3d model. So for every point (x,y) in 2d, there would be a point in 3d (x,y,z=(intensity of(x,y))/(maxintensity-lowestintensity)*scale), where your scale is something you define. However you would have to define how to connect these points in 3d using GL.Polygons, GL.Triangles, etc. Your normals would be the cross product of dx and dy. If intense2d(x,y) corresponds to the color or intensity in your 2d terrain, depending on how its defined in your terrain map. Your basic code would be:
float maxint = maximum intensity in your 2d terrain.<br />
float minint = minimum intensity in your 2d terrain.<br />
float scale = maximum altitude/maximum intensity in 2d terrain.<br />
float zscale = scale*(maxint-minint)<br />
for each x and y in 2d image <br />
float dx= intense2d(x+1,y)-intense2d(x,y), dy=intense2d(x,y+1)-intense2d(x,y);<br />
//Your normal would be the cross product of dx and dy as vectors<br />//Vector and cross product you define yourself of course.<br />
Vector norm = cross(new Vector(1,0,dx), new Vector(0,1,dy)); <br />
Gl.glNormal3f ( (float)norm.x, (float)norm.y, (float)norm.z );<br />
// set the color if you haven't alreayd<br />//Gl.glColor3f(rcolor,gcolor,bcolor);<br />
Gl.glVertex3f ( (float)x, (float)y, (float)intense2d(x,y)/(zscale));
If you are putting this terrain onto an object, then you might not neccesarily want to set the height, but just the normals at their corresponding location, which is bump-mapping.
This is the basic idea, otherwise you would have to be more specific.