|
lindiwe wrote:
This will assist me the next time i go to class coz i wont be behind.
Yes, you will be!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a label that when it is clicked, a text appear. How do I make it toggle?
Click once appear, click again disappear?
thanX for any suggestions
|
|
|
|
|
You can use a boolean.
boolean isShow;
if(isShow)
{
showText
isShow=false
}
else
{
don`t show text
isShow=true
}
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
|
I created a windows with 5 tabs. On the design mode the taps appeared correct, when I look in the tab page (collection) property, they look OK but when I compiled the application, they are out of order.
Any ideas?
|
|
|
|
|
I ran into this problem b4, it seems to be a little bug in VS.NET You need to manually change the order that the Tab Pages are added to the TabControl in the InitializeComponent() method of your code.
Find where your TabControl is initialized and change the order in which the Tab Pages are added to the Controls collection. This will fix your problem.
|
|
|
|
|
OK. I was able to set the Form1.isMDIContainer property to true on the main form to prevent an exception from being thrown when showing a child form. Than I created a MDIChild form triggered by a menu item as the article from Microsoft says at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconMDIApplications.asp but I encountered a problem.
First, when the Form.isMDIContainer property of the main form is set to true, it causes the background property of the form to only show a system color rather than the color that I would like the main form to display. This is explicitly stated in the article link above from Microsoft. Therefore, I thought that I could put a panel on the main form to display the color that I selected for the main form, but now when the MDIChild form is displayed it is displayed BEHIND the panel that was added to the main form.
How do I get the MDIChild form to display IN FRONT OF the panel rather than behind the panel. I tried to set the code in a menu item like so but it did not work.
<br />
formChild frm = new frmChild();<br />
frm.MDIParent = this;<br />
frm.Show();<br />
The MDIChild form shows behind the panel. I had tried to change the code to frm.MDIParent = panelMain but it would not assign a panel to a form. I find it very hard to believe that I am forced to choose either between a gray background (system color) OR the possibility of MDI form functionality.
I would appreciate some additional input from an MDI expert who has done some sort of a work-around solution. The color that I want to use for the background color of the main form is simply not in the list of system colors. Need your assistance to either bring the MDIChild form in front of the panel or to change the color permitted for the parent form from a system color. Tried to set the MDIChild form TopMost property to true but that did not work either. Any suggestions?
|
|
|
|
|
|
Dave:
Thanks for providing me with that information. I attempted to convert the VB.NET code into C# code. Please look closely at it and tell me if you think I got something wrong. In addition, I still have one question.
<br />
MdiClient ctrlMDI;<br />
<br />
foreach (Control ctrl in this.Controls)<br />
{<br />
try<br />
{<br />
ctrlMDI = CType(ctl, MdiClient)
ctrlMDI.BackColor = this.BackColor<br />
}<br />
catch<br />
{<br />
<br />
}<br />
}<br />
The problem that the first line has is that there is not any CType conversion extraneous module inside C# of which I am aware. I attempted to use code like thus:
<br />
Convert.ChangeType(ctrl, ctrlMDI);<br />
but that doesn't work either. Besides, most of the Convert class methods are dedicated to methods like Convert.ToInt32() and Convert.ToString(). Could you kindly enlighten me about what the C# equivalent is to CType() with which many people are familiar in ASP.NET and VB.NET? Would appreciate it.
|
|
|
|
|
You might want to try
ctrlMDI = (MdiClient)ctl;
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Trying to get a button within a datalist to fire an event. However on the coding I'm not sure how to link to the button within the datalist.
My data list is called dlorders and the button is called btnEdit and carries a commandname edit. which then should fire code to open up 2 other buttons, cancel and update.
The label1.text is just test to see if code is firing which it aint!
public void dlOrders_Edit(object source,System.Web.UI.WebControls.DataListCommandEventArgs e)
{
//Turn on editing controls
dlOrders.EditItemIndex = e.Item.ItemIndex;
//Re-bind the data
sqlDataAdapter1.Fill(dsOrders1,"Orders");
DataBind();
Label1.Text = "Done";
}
have a created it right?
|
|
|
|
|
At the very least you would need a Label1.InValidate() or Label1.Refresh() after setting the text. Even then, you may have paint issues under some circumstances. It might be better just to set a form scope private boolean, and use it in the idle loop to do the refresh of the control states.
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
Hello there!
At the moment, I am trying to create an export function for my graphical statistics.
For the creation of the statistics, I am using functions like
g.FillRectangle(...);
g.DrawString(...);
and so on.
I now want to export this graphics object to a jpeg-file (and later on, into Excel).
What would be in your opinion the best method to do so? Is it somehow possible to create a Bitmap-object and export it as a file?
Any help greatly appreciated
zaubara
|
|
|
|
|
Best I have come up with so far is to do a screen capture to a bitmap (programatically), then save that as a jpeg. I have also saved to a windows metafile, which renders and scales much better in IE.
A code snippet
IntPtr h = gridCtrl1.Handle;<br />
Graphics g = Graphics.FromHwnd(h);<br />
Rectangle rectA = gridCtrl1.Bounds;<br />
rectA = gridCtrl1.Parent.RectangleToScreen(rectA);<br />
Rectangle rectP = gridCtrl1.RectangleToClient(rectA);<br />
IntPtr gridHDC = User32dll.GetDC(gridCtrl1.Handle);<br />
IntPtr gridCapture = Gdi32dll.CreateCompatibleDC(gridHDC);<br />
IntPtr gridBmp = Gdi32dll.CreateCompatibleBitmap(gridHDC,rectP.Width,rectP.Height);<br />
if (gridBmp != IntPtr.Zero)<br />
{<br />
IntPtr tempHDC = (IntPtr)Gdi32dll.SelectObject(gridCapture,gridBmp); <br />
Gdi32dll.BitBlt(gridCapture,0,0,rectP.Width,rectP.Height,gridHDC,rectP.Left,rectP.Top,Gdi32dll.SRCCOPY); <br />
Gdi32dll.SelectObject(gridCapture,tempHDC);<br />
<br />
Bitmap b = Image.FromHbitmap(gridBmp);<br />
string imageFilePath = System.IO.Path.GetTempFileName();<br />
imageFilePath = imageFilePath.Replace(@".tmp",@".wmf");<br />
b.Save(imageFilePath,ImageFormat.Wmf);<br />
Gdi32dll.DeleteObject(gridBmp);<br />
}<br />
User32dll.ReleaseDC(h,gridHDC);<br />
Gdi32dll.DeleteDC(gridCapture);
User32dll & Gdi32dll are classes encapsulating the appropriate DLL imports
gridCtrl1 is a user control containing the graphics image created with the System.Drawing functions like yours.
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
You can create a bitmap, make a graphics object for it, do your drawing and finally save the bitmap to a file:
<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
<br />
Bitmap b = new Bitmap(requiredWidth, requiredHeight);<br />
using (Graphics g = Graphics.FromImage(b)) {<br />
g.FillRectangle(...);<br />
g.DrawString(...);<br />
}<br />
b.Save("C:\\bla.jpg", ImageFormat.Jpeg);<br />
|
|
|
|
|
Huge thanks for both of your ideas!
I already tried to do a screenshot which sorta worked - it shot my complete desktop (which is an easy-to-solve problem) and I had the popup on top of my picture, which is not too great
Right at the moment, I create my Graphics object out of a panel like this:
Graphics g = pnl_painting.CreateGraphics();
Is it possible to create a bitmap and the graphics object like you said, save it AND draw the bitmap in that panel?
Or I could actually create that bitmap on the fly (I save all the needed data in ArrayLists) and leave the rest unchanged, mhm ...
One more thing: how can I export an image to an excelsheet? TIA
|
|
|
|
|
You could do the following:
1. Create a bitmap with the same size as your panel
2. Get a Graphics object of your bitmap with Graphics.FromImage
3. Do your drawing on this Graphics object
4. Save the bitmap with Save
5. Make the Graphics object of your panel (pnl_painting.CreateGraphics())
6. Call DrawImageUnscaled(bitmap, 0, 0) on it
If you leave step 4 out the panel will still be painted correctly but just no file will be created.
With your question regarding excel I cannot help you, but if I remember right there has to be a very good article about automating ecxel here on codeproject.
|
|
|
|
|
Ok, I will check that article out!
Thanks a lot!
|
|
|
|
|
I have a richTextBox control that I load text files into. What is the best way to format and align the text loaded. Also, which control is best to use for this purpose, textBox or richTextBox.
|
|
|
|
|
A TextBox doesn't have a concept of alignment, so you'll have to use the RichTextBox. There's a SelectionAlignment property that does just what you want.
Regards,
mav
|
|
|
|
|
How can I add a DataRowCollection directly into a DataTable? Is there a way besides looping through all the datarows and adding each row to datatable?
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Not sure what you're asking here. Do you mean you have a DataRowCollection from one table, and you'd like to add its contents to another table? If so, why? Are you cloning a datatable or something?
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Ok I have a server that is listening for incoming requests on ports 9000 through 9010.
That being said, here is the quandry I have. If two people happen to grab port 9005, would the first person to get there lock it down. I mean if the second person gets there at the same time how can I direct the client app to try to reconnect on an other port.
Any ideas or sample code would be welcome.
|
|
|
|
|
Only one socket can listen on a particular port. But more than one socket can connect to a single port. From your question, it is not clear whether you meant the first or the second.
In the first case, the call to Listen() will fail with an exception.
Regards
Senthil
My Blog
|
|
|
|
|
Try reading on "non-blocking server socket" in the MSDN.
The thing is: if you have a "server loop" which waits on data to arrive on any of these ports, then does some manipulation and loops, you will always have poor performance, as your application will block until you are done with one of the requests.
If you decided to use 10 ports in order to offer "10 parallel connections", you totally misunderstood the concept (sorry ).
You should only use different ports for different services (e.g. FTP Control connection on Port 21, HTTP on Port 80, ...) or to seperate user-groups (e.g. Customer1 connects to FTP on port 21, Customer2 uses Port 23, ...).
Specifically, you might want to read into Delegates, Callbacks, etc. These are, IMHO, the easiest way to create socket-using apps without doing manual multithreading.
Cheers
Sid
|
|
|
|