|
Hi,
I see no reason to use bitmaps for this.
As long as you get the drawing to look the way you want it to look,
by just using a couple of Graphics drawing primitives, just do that.
If the intended result requires a lot of shading, reflections, whatever (so it looks
more like a picture, not a computer generated drawing), then you might want to switch
to bitmaps.
|
|
|
|
|
I've done a decent amount of C++ in school last year (college level work) and I was interested in giving a GUI C# work a go.
I have experience in a couple BASIC languages and Java, that coupled with my C++ experience has made it fairly painless so far.
I have a class called "UpdateTimer" that obviously implements a Timer object. The class is passed the data class from where it gets all of its data. However, once it has completed, I want it to refresh the data in two labels.
I have tried both referencing to the lables directly and the method in Form1.cs that called "refreshData()" both with no luck.
I am lost on what to do. I am sure that my methodology is wrong. I would like to be able to implement the timer outside of the Form1 class.
Thanks for any assistance!;P
|
|
|
|
|
You're writing your own timer object? .Net provides timers for you - there's the Timers.Timer[^] for general all purpose use, and the Windows.Forms.Timer[^] for thread-safe use with Windows Forms.
If those don't suit your fancy, what kind of problems are you having with the "UpdateTimer" class?
|
|
|
|
|
hi guys:
can everyone tell me, what is interface, why do we use interface and when do we use interface?
thanks
|
|
|
|
|
A quick Google[^] would reveal the answer. Ok the page is in VB but it demonstrates the concept, basically an interface is a contract. When you implement an interface you are basically signing an agreement that you will implement all the fields, properties and methods defined in the interface. You can then rather than dealing with definite objects you can deal with the common interface without having to know what the underlying type is.
It's commonly used in plug in[^] based systems.
|
|
|
|
|
Hi All,
I have a page that is used in two separate scenarios, either directly linked in the web application, or as a popup using window.open. On this page is a datagrid with three columns i care about, column1 is just some information (a KeyWord) and defaulted to visible=false for when the page is used as a popup, column2 is the same information but used as a link when the window is a popup, and column3 is a select command item also default to visible=false.
basically, i want it so that when used as a popup:
column1 = visible false
column2 = visible true
column3 = visible false
when linked in the main window:
column1 = visible true
column2 = visible false
column3 = visible true
(the exact opposite)
I want to be able to check onload the page's status, and change the visibilities accordingly. Changing the visibility is easy enough, but i can't find a way to check whether or not this page is a popup (window.opener != null) or not (window.opener == null) using server side code.
Any help would be appreciated
|
|
|
|
|
Craigpt wrote: i can't find a way to check whether or not this page is a popup (window.opener != null) or not (window.opener == null) using server side code.
You can't. The browser doesn't tell the server where the page will be displayed, so the server simply doesn't know.
If you put a value in the querystring that reflects how the page is used, the server can check that value.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: The browser doesn't tell the server where the page will be displayed, so the server simply doesn't know.
Ok thanks, that's what i needed to know. I remembered the popup window already had querystrings in the URL so i just used the presence of those to decide.
|
|
|
|
|
Wouldnt' this be more appropriate in the ASP.NET forum?
|
|
|
|
|
Ya, it was a toss-up for me, but i decided that in the ASP.net forum i ran the risk of getting a VB.Net answer, and if code was available i wanted it in C#
|
|
|
|
|
There isn't that much difference and both can easily be translated between the other, besides you could always just ask for it to be given in C#.
|
|
|
|
|
Hi everybody!!!
How I can use ErrorProvider in DataGridView??? (It is for notice when the input data in some field is failur. In this case you mast see blinking of ErrorProvider in some field)
|
|
|
|
|
Use the ErrorText property:
<code>private void dgv_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv.IsCurrentCellInEditMode)
{
dgv.Rows[e.RowIndex].ErrorText = "You made an error";
}
}
|
|
|
|
|
Thak you for help! But I want to put ErrorProvider in field of DataGridView! So I add:
<br />
private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)<br />
{<br />
DataGridView dgv = sender as DataGridView;<br />
if (dgv.IsCurrentCellInEditMode)<br />
{<br />
dgv.Rows[e.RowIndex].Cells[0].ErrorText = "You made an error!"; <br />
}<br />
} <br />
|
|
|
|
|
Check this code.
Two questions:
1. After opening the serial port do I need to worry about closing the port as when I return (leave the using scope) the object will automatically be disposed?
2. If the code enters the catch block will the serial port object automatically be disposed after leaving the using scope?
Thanks!
public static bool IsPortInUse(string portName)
{
try
{
using(SerialPort sp = new SerialPort(portName))
{
sp.Open();
return false;
}
}
catch (UnauthorizedAccessException e)
{
return true;
}
}
|
|
|
|
|
the "using" scope automatically calls the dispose method (if available) upon leaving, whether through normal means or if it errors
|
|
|
|
|
Thanks for your reply. So what I'm doing is ok? i.e the serial port will be disposed in all cases when it leaves the using scope?
|
|
|
|
|
as far as i can tell, and my coworker agrees, it should work great
|
|
|
|
|
Cheers!
|
|
|
|
|
No problem! Happy coding!
|
|
|
|
|
If the code execution leaves the using scope for any reason, the object's Dispose method is automatically called and the object free'd.
|
|
|
|
|
Thanks for your reply. I was pretty sure that was right. Hey, but if an object doesn't implement IDisposable is there any point in using Using?
|
|
|
|
|
TheTinSoldier wrote: if an object doesn't implement IDisposable is there any point in using Using?
If it doesn't implement IDisposable, you will get a compiler error if you try to use it in a using block.
|
|
|
|
|
|
It actually compiles to something like this:
public static bool IsPortInUse(string portName) {
try {
SerialPort sp = null;
try {
sp = new SerialPort(portName);
sp.Open();
return false;
} catch (Exception ex) {
throw ex;
} finally {
if (sp != null) {
sp.Dispose();
}
}
} catch (UnauthorizedAccessException e) {
return true;
}
}
Which will automatically dispose, even if an exception occurs.
|
|
|
|