|
Thanks for the reply. I actually figured this one out before you replied, but your reply sounds like a more permanent solution then what i did.. (i used the decimal data type, which worked until 100%)
|
|
|
|
|
Hi,
when you do an assignment such as
destinationVariable = someExpression
then the type of the destinationVariable is irrelevant while someExpression is
evaluated. So when e.g. someExpression consists of only integers, it will be calculated
using only integers (with possible overflow); it is only when the assignment itself
is going to happen that possibly a conversion (up-casting) will happen.
BTW: same is true for most programming languages (C, C++, Java, ...).
If the expression's type is insufficient to evaluate correctly, you must make sure
a more capable type is used (e.g. by using wider constants such as 1.0 which
causes part of the expression at least to use doubles, by using a long/float/double
variable, or - at the right place - inserting a long/float/double cast).
|
|
|
|
|
Hey guys,
I have a PictureBox on a form, it has lines drawn on it via
Graphics g = thisform.CreateGraphics();
g.DrawLine(p, ps, pe); // connecting dots ps and pe, p is the pen
However, whenever I minimize the form the contents are lost, or if I bring something on top of these picture boxes the portion that was covered is lost-
How can I make the drawings persistent!? Thanks for your help.
raheel
|
|
|
|
|
Hi,
the normal way to draw things is to add drawing commands to the Paint handler;
that code gets executed whenever the drawing got damaged (e.g. after a Minimize)
or when Invalidate() gets called.
As a consequence you need data structures that represent everything that needs to
be drawn inside the Paint handler; when doing animation, a timer would in its
tick handler modify the data, then call Invalidate().
|
|
|
|
|
rbengali3 wrote: Graphics g = thisform.CreateGraphics();
Never, ever, do this, unless you want to draw something temporary and easy to erase.
Your picture box is a waste of time, it's a control for easy showing of a bitmap. If you're drawing lines, the control never does anything.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Thanks for the reply Luc.
Christian, I don't understand. Should I skip the picture box completely and draw directly on the form with simmilar code?
Thanks
|
|
|
|
|
You should NEVER use CreateGraphics to draw things you don't want to lose. Yes, you should draw directly onto the form, using the paint event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
when you minimize the window, all the unfocused or unused parameters be collected to the garbage, so you need to keep focus in the picturebox by drawing in a timer;)
|
|
|
|
|
I am really stuck trying work out and understand how to achieve the following. I have a collection of objects and want to peform some data analysis on each of the fields in turn using a method.
The collection
List<CardData> CardDataCollection = new List<CardData>();
CardData class contains fields called Card1,Card2,Card3 etc
The code below has been simplified to show what I'm currently doing for one of the collection object fields (CardDataCollection[i].Card1 ).
public static void CalcData()
{
int i;
for (i = 0; i < CardDataCollection.Count; i++)
{
if (CardDataCollection[i].Card1 == 1)
{
}
}
}
I need to perform the same exercise on each of the Card fields (for Card1 upto Card100) in the collection so I want to create a method that will allow me pass in some kind of reference to the collection object field (CardX ).
Note: I need access using the [i] as the data processing requires me to use for example [i-5] (i.e can't use foreach loops)
I know what I want it do but just can quite get my head around how to do it. I'll try to explian below how I would change the code.
public static void CalcData(reference to relevant card number field eg Card50)
{
int i;
for (i = 0; i < CardDataCollection.Count; i++)
{
if (Card50[i] == 1)
{
}
}
}
Please excuse any incorrect technical description as I'm only new to this C#. Thanks in advance for any help you can give me.
Haz
|
|
|
|
|
haz13 wrote: I need to perform the same exercise on each of the Card fields (for Card1 upto Card100)
Why don't you use a card array of size 100?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Sorry Greeeg I don't understand how that would help what I'm doing (please explain more - maybe I haven't explined it very well)? Basically I need to itterate through all the collection object fields in turn. I have a method that does it for one of the fields, but instead of copying it 100 times and slightly changing the field refernces I was trying to create a method that was more generic (this is the bit I can't get my head around).
CardDataCollection[0].Card1
CardDataCollection[1].Card1
CardDataCollection[2].Card1
CardDataCollection[3].Card1
CardDataCollection[4].Card1
CardDataCollection[5].Card1
to end of collection
Then I need to do the same for the Card2 field
And so on for each of the remaining Card fields upto 100
CardDataCollection[0].Card100
CardDataCollection[1].Card100
CardDataCollection[2].Card100
CardDataCollection[3].Card100
CardDataCollection[4].Card100
CardDataCollection[5].Card100
to end of collection
Put another way I need one method to prevent me creating 100 very similar methods as described below.
public static void CalcDataCard1()
{
int i;
for (i = 0; i < CardDataCollection.Count; i++)
{
if (CardDataCollection[i].Card1 == 1)
{
}
}
}
public static void CalcDataCard2()
{
int i;
for (i = 0; i < CardDataCollection.Count; i++)
{
if (CardDataCollection[i].Card2 == 1)
{
}
}
}
public static void CalcDataCard3()
{
int i;
for (i = 0; i < CardDataCollection.Count; i++)
{
if (CardDataCollection[i].Card3 == 1)
{
}
}
}
Thanks again for any help.
Haz
|
|
|
|
|
haz13 wrote: (for Card1 upto Card100)
As someone else said, instead of having 100 fields, have a collection which contains them ( and if they are named card1-card100, an array makes sense, you just put the number in the indexer ). Then you can iterate over them with foreach to do your test.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 all,
l made a class and i want to export its values stored in members data to an excel file
can any one give me a beginning
my class like
<br />
static class Export<br />
{<br />
private static ArrayList arrivalRate = new ArrayList();<br />
private static ArrayList customersNo = new ArrayList();<br />
}<br />
and i wanna to make member data is the header of the row and the values in the arraylist are in squence in the adjacent cells.
also i wanna to ask about automatic documentation, i used SandCastle but i cannot deal correctly with it, so can any one give me a program that only executable file i give it the file path only like what happened in javadoc.exe
thanx
Generator
|
|
|
|
|
|
Hi,
thanx for ur help ur information make me make it successfully
thanx alot
Generator
|
|
|
|
|
glad to help
|
|
|
|
|
Hello. I have a combobox with a couple of items in it. Instead of having a label on the form that describes the content of the combobox id like to use the textproperty for this purpose. So far so fine. But now I want to change the textproperty of the combobox to italic but leave the rest of the items in the combobox as regular text. Anyone knows how I can do this.
As it is now when i change the combobox.Font.Italic prop all the items in the collection is set to italic.
//Thx
|
|
|
|
|
It's all or nothing using the standard control.
If you wanted more control over the textbox and the list fonts, you'd have to create your own version that supports this, supplying the properties to be set for each side of the control and supplying all the rendering code to draw the textbox and the drop down list.
|
|
|
|
|
I have a program that will connect to an FTP site with InternetConnect() if I use my Windows dialer.
If I try to connect to the FTP site using another dialer there is no connection to FTP site.
My Windows dialer has my user name and password for my ISP, but the other dialer does not, it just dials and connects.
I am confused, how can the other dialer connect without my ISP username and password? This is probably why I cannot connect to FTP site.
I can make a connection with the other dialer using HTTP settings and using a www.myspace.net address, but if I switch over to FTP settings and use ftp.myspace.net, no connection.
Please excuse me if I sound confused, I am, and I can't seem to get my brain wrapped around these concepts.
Thanks for any help.
|
|
|
|
|
Hi,
Is it possible to assign a null to a DateTime value type? If not, what then?
Regards
ma se
|
|
|
|
|
ma se wrote: Is it possible to assign a null to a DateTime value type?
No, it's not.
You can only assign null to a reference, and as DateTime is a value type, there is no reference.
ma se wrote: If not, what then?
If you are using framework 2.x, you can use the nullable types:
DateTime? when;
if (something) {
when = null;
} else {
when = DateTime.UtcNow;
}
if (when.HasValue) {
Console.WriteLine(when.Value.ToString("yyyy-MM-dd"));
} else {
Console.WriteLine("No time specified.");
}
If you are using framework 1.x, you have to do something else to keep track of when there is a value or not, like using a bool variable along with the DateTime variable.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for the reply, but I struggle to see where you assigned it a nullable value?
|
|
|
|
|
It's the question mark behind the type name.
See this for more information:
http://msdn2.microsoft.com/en-us/library/1t3y8s4s(VS.80).aspx
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You can solve this with a nullable type (since .NET 2.0)
or you might be able to set aside one value and let it represent the "has no value" situtation;
in case of DateTime it probably would be DateTime.MinValue
|
|
|
|
|