|
IIRC you need to set the FormStartupPosition property to Manual . You need to set both the Location and Size in parent coords.
|
|
|
|
|
Hello
I'm pretty new for the most part to programming in C# and I'm attempting to do something that I haven't been able to locate a solution for. Any help would be appreciated.
I have a text file with data in it that looks kind of like this:
BHG0002304050
BHG9459895944
BHG94859489568
I was able to write a snippet of code that would read that information into a string array so it looked like this:
Array[1] = BHG0002304050
Array[2] = BHG9459895944
Array[3] = BHG94859489568
However, I now want to separate each character within the array into it's own array... so it would look like this:
array1[1] = B
array1[2] = H
array1[3] = G
array1[4] = 0
etc.
I'm not sure I'm doing this the correct way so any help would be appreciated. If you have any suggestions on how to do this a different way then I'm explaining it I'm very open to ideas.
The reason for this is I will be using each of these characters in this datafile into a mathematical formula, each line represents a math formula... so I need to keep each line separate but I need to pull each character from each line if that makes sense.
thanks!
|
|
|
|
|
string[] t = reader.ReadToEnd().Split('\n');
char[][] all = new char[t.Length][];
for (int i = 0; i < t.Length; i++)
{
t[i] = t[i].Trim('\r');
all[i] = t[i].ToCharArray();
}
|
|
|
|
|
Thanks for the quick response.
This example really helped me get it figured it.
-- modified at 15:34 Friday 19th May, 2006
|
|
|
|
|
You can access the chars of each string directly:
Array[1].Chars[0] = B
Array[2].Chars[3] = 9
etc.
Scott
|
|
|
|
|
please help!
i am working in a c# GDI+ application but i got a problem in producing a pure flickering free screen, i am drawing on a panel and am using the following way to double the buffer but no use!
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
<br />
<br />
Graphics g = this.panel1.CreateGraphics();<br />
offScreenBitmap = new Bitmap(this.panel1.Width,this.panel1.Height);<br />
Graphics g2 = Graphics.FromImage(offScreenBitmap);<br />
Brush b = new SolidBrush(this.panel1.BackColor);<br />
<br />
g2.FillRectangle(b, new Rectangle(this.panel1.Location,this.panel1.Size));<br />
g2.SmoothingMode=SmoothingMode.AntiAlias;<br />
flowChart1.Draw(g2);<br />
<br />
g.DrawImage(offScreenBitmap, new Point(0,0));<br />
g2.Dispose();<br />
b.Dispose();<br />
<br />
}
but i still have flickering screen, where is the problem?
and i am trying the the following code to double the buffer
SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(ControlStyles.DoubleBuffer, true);<br />
SetStyle(ControlStyles.UserPaint, true);<br />
SetStyle(ControlStyles.ResizeRedraw, true);
but dose't work!
reply asap please!!
|
|
|
|
|
See-S wrote: Graphics g = this.panel1.CreateGraphics();
You should not have to Create the graphics. Rather handle the Paint event seperately.
|
|
|
|
|
You aren't using the Graphics object attached to the Panel's off-screen buffer because you're calling CreateGraphics() on the Panel. Use e.Graphics instead.
Josh
|
|
|
|
|
thanks leppie and Josh!
i see, but again it doesn't work.
but now i substituted a pictureBox for the panel and itworks well!
thanx
|
|
|
|
|
There is the thing: I need to create a Vitrual Drive wich is mapped into a file (an XML one).
This file needs to simulate a tree stucture from the disk.
Is there a .Net way to do this?
... Just asking
www.brusella.com.ar[^]
|
|
|
|
|
Gonzalo Brusella wrote: Is there a .Net way to do this?
No.
You can however make a container file, and a viewer for it, but this wont be viewable by Windows itself.
|
|
|
|
|
The only way is with IoCreateDevice and with C++??
Hmmmm... A LONG work waits me....
|
|
|
|
|
Gonzalo Brusella wrote: Hmmmm... A LONG work waits me....
I think so.
A while ago I tried the same, knowing already that it's not possible to do it in .NET, and since I'm not used to "classic" Win32 APIs, I simply gave up.
Anyway if you're going to do it, we'll all appreciate an article on that topic here at CP.
______________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] and the ScrewTurn Software experiment
|
|
|
|
|
Thanks to everyone who helped with my previous question. I soon realized, however, that what I really need to do is to be able to cast the type, such as:
- This code is hypothetical, as to not complicate things further, but the real object in the program I am working on is a crystal report, but I want the viewer to work with any crystal report without having to hard code the viewer each time I create a new report. But if someone was able to answer this question, I could take it from there.
object SomeFunction ()<br />
{<br />
return UnknownObject;<br />
}
Now, while I dont know exactly what type UnknownObject is, I am sure no matter what it has a method called, lets say, ClearNum() - ya, kind of stupid, but Im trying to keep it simple to try to avoid getting an overcomplicated answer.
So lets say I want to ClearNum() on the object regardless of what type of object it is.
How can I accomplish the following:
void OnFormClose ()<br />
{<br />
object o = SomeFunction();<br />
((o.GetType())o).ClearNum();
}
Thanks if anyone knows the answer It would help me be a much better programmer.
|
|
|
|
|
If the UnknownObject always has ClearNum() then it is likely that all objects returned by the SomeFunction might implement some interface or derive from a common base class. If so, you can catch the return value as that type and go from there. Else, use reflection to call ClearNum via a dynamic method invocation.
Josh
|
|
|
|
|
Thanks so much, It never occurred to me that I could use methods from the common base class once a new class was derived from it - that was a big help!
|
|
|
|
|
I have 2 questions regarding array manipulation:
1) which is the best way to reset an array if i initially declare as:
private byte[] array1 = new byte[0];
2) how to insert elements into array at a specified index e.g:
initial array = [1,2,3,4,5]
new array = [1,2,7,8,3,4,5]
Ragards,
Donkaiser
|
|
|
|
|
You can't insert elements into an array. It is immutable. Try an ArrayList instead. Once you've finished manipulating it, you can convert it back to an array if you want.
Kevin
|
|
|
|
|
so how do I convert my array into a list? and backward?
Thx
Donkaiser
|
|
|
|
|
ArrayList has a ToArray() method, and your array can be added one by one to a new ArrayList when you create it, or using the AddRange method
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
ArrayList list = new ArrayList( myArray );
int[] ia = list.ToArray( typeof(int) ) as int[];
|
|
|
|
|
while reconverting back to array of bytes i got an InvalidCastException error message:
"At least one element in the source array could not be cast down to the destination array type."
byte[] myArr = (byte[])myList.ToArray(typeof(byte));
why can't it cast every object to the specified byte type?
Donkaiser
|
|
|
|
|
There must be something in the ArrayList which is not a byte (or not able to be converted to a byte).
Josh
|
|
|
|
|
You are linkely adding ints to the Arraylist, make sure you cast them to byte before adding.
|
|
|
|
|
In answer to both questions, when you need to work with arrays dynamically, use collections (or in .NET2 List<> ).
The reasons
1) Collections can be cleared with a .Clear() method
2) Collections allow dynamically adding (.Add(value) ) and inserting (.Insert(index,value) ) new items.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|