|
Hello,
How can I write the DataSet Contents into a CSV file?
Thank you.
|
|
|
|
|
Assuming there is only one DataTable in the DataSet then you can just iterate through the rows of the DataTable, then iterate through each of the columns writing the information to a file. Each column iteration loop writes a comma after the value, except the last iteration. Each iteration of the rows writes a newline after writing out the columns, except for the last row.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hi,
I'm just starting out with DirectX and am running into some trouble (I've been piecing parts of examples together). I have a couple rectangles that yaw, roll, and pitch as they zoom in. When they come back to face the front (so it only looks 2d), I stop the movement and add a couple triangles. Up to here it works just fine. Now I'd like to add a bitmap under the rectangles but run into trouble. I have:
private override OnPaint()<br />
{
some twirling of boxes for a few seconds that become still with this line:
DrawBox(0.0f, 0.0f, 0.0f, -0.45f, 0.8f, 9.5f); (code for DrawBox below)
then I add a couple triangles...
CustomVertex.TransformedColored[] vert = new CustomVertex.TransformedColored[3];
... describe the vert ...
device.VertexFormat = CustomVertex.TransformedColored.Format;<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vert);
Things work fine up to here. At this point I'd like to add my bitmap (Texture tex). I change the VertexFormat and call DrawBitmapBox (this is how one example added a texture to a box):
device.VertexFormat = CustomVertex.PositionTextured.Format;<br />
device.SetStreamSource(0, vb, 0); vb is the VertexBuffer - also below
DrawBitmapBox(0.0f, 0.0f, 0.0f, 2.0f, 2.0f, 9.5f, tex); (code also below)
}
Instead of drawing the bitmap image, the original rectangles themselves kind of blink (not at any contant rate), while the triangles just sit there like everything's ok. I know I'm probably making some obvious mistake(s), but any help in getting this bitmap up would be great!!!
Mel
DrawBox
private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z)<br />
{<br />
angle += 0.01f;<br />
device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
Material boxMaterial = new Material();<br />
device.Lights[0].Type = LightType.Directional;<br />
device.Lights[0].Diffuse = Color.Red;<br />
device.Lights[0].Direction = new Vector3(0,-1,-1);<br />
device.Lights[0].Commit();<br />
device.Lights[0].Enabled = true;<br />
boxMaterial.Diffuse = Color.White;<br />
device.Material = boxMaterial;<br />
mesh.DrawSubset(0);<br />
}
DrawBitmapBox
<br />
private void DrawBitmapBox(float yaw, float pitch, float roll, float x, float y, float z, Texture t)<br />
{<br />
angle += 0.00f;<br />
device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);<br />
device.SetTexture(0, t);<br />
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 6);<br />
}
VertexBuffer stuff
under InitializeGraphics:
vb = new VertexBuffer(typeof(CustomVertex.PositionTextured), 6, device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);<br />
vb.Created += new EventHandler(this.OnVertexBufferCreate);<br />
OnVertexBufferCreate(vb, null);
OnVertexBufferCreate:
private void OnVertexBufferCreate(object sender, EventArgs e)<br />
{<br />
VertexBuffer buffer = (VertexBuffer)sender;<br />
<br />
CustomVertex.PositionTextured[] v = new CustomVertex.PositionTextured[6];<br />
v[i] = ...<br />
buffer.SetData(v, 0, LockFlags.None);<br />
}
|
|
|
|
|
Are the dimensions of your bitmap powers of 2? If I recall correctly they have to be powers of two to work as textures.
I hope this helps.
Deus caritas est
|
|
|
|
|
Hi,
I am making a program and in the menu bar I did a menu bar item called About. Now I would like that when I open the About form the main form will be disabled. I did that and it worked. But now how should I make it enabled again after I close the About form?
Thanks a lot
|
|
|
|
|
Hi,
You want to display your about form as a modal dialog:
private void menuItemHelpAbout_Click(object sender, System.EventArgs e)
{
FormAbout dlg = new FormAbout();
dlg.ShowDialog();
} This will "disable" your main form while the about box is shown.
----------------------------
Be excellent to each other
|
|
|
|
|
I don't think you understood me. I disabled the form but I would like that when I close the About form, the main form will be enabled again. How can I do that?
thanks
|
|
|
|
|
hi
I use an aaplication which write to a log file every ~ 1sec.
i need to build an appliaction that will display the contents of this and updtae the display as it works.
i tried using StreamReader but was unsuccessful i get sharing violation when both apps trying to access the file.
please help.
Have a nice Day
|
|
|
|
|
i think you need to use different threads for reading and writing, so as not to try to do both simultaneously. You will probably need to use lock keyword, as well as Monitor.Pulse and Monitor.Wait methods.
Try reading the help on these and have a nice day too.
there are no facts, only interpretations
|
|
|
|
|
I am using the Win32 GetClassInfoEx to get the small icon of a window from another application. GetClassInfoEx returns a IntPtr to the 16x16 small icon.
How do i put the image located at this IntPtr into a Bitmap so that i can use it in NET? There does not seem to be a function in NET that converts an image pointer into an image.
I have hit a brick wall. Can someone nudge me in the right direction about what to do?
|
|
|
|
|
Try:
Bitmap bitmap = Bitmap.FromHicon( hicon );
----------------------------
Be excellent to each other
|
|
|
|
|
|
I've only just started with c# so these are probably stupid questions.
1. Why is it displaying certain information (for example CommandLine from Win32_Process) throws up a NullReferenceException, yet other information from the same collection works fine and how would I go about avoiding this (ie; actually getting the information rather than just handling the exception,) I'm displaying the information in a list view fwiw, using
foreach (ManagementObject MO in processQueryCollection)
{
ListViewItem processItem = new ListViewItem(MO["Whatever"].ToString());
processItem.SubItems.Add(MO["Whatever"].ToString() + " Bytes");
......
lstProcesses.Items.AddRange(new ListViewItem[] {processItem})
}
You get the idea.
2. What would be the best way to update the list view on a timer event ? I've got the timer working but obviously if I call the method that contains the above code it replicates the data, adding new columns and rows rather than updating the existing data and if I call a clear method it ends up looking very strange.
TIA.
|
|
|
|
|
1. This point is pretty simple, there could be many cases where you are trying to access a property of a null item which is throwing the exception.
For example, if MO["Whatever"] doesn't return a valid object, it returns a null. You are then trying to access the ToString() method over this object, which is actually null, so it is like null.ToString(). You cannot access any of the properties on null.
Ideally you must perform checks like
object temp = MO["Whatever"]
if (temp != null)
{
processItem.SubItems.Add(temp.ToString() + " Bytes");
}
Note: Null checks must be a "taken for granted" coding style.
2. I am thinking, don't clear the list. You then use listView.Contains(..) method (or a similar implementation by you) to first check if the new item is present and if it is, don't add it.
Add a reference to all the current items of the list view not checked to a collection. This will be the list that got removed (if you need that) and then remove these items from the list. There will be much less confusion this way.
There has to be more to life than just this
-- modified at 1:01 Friday 24th February, 2006
|
|
|
|
|
I have a variable defined as public in form1 and am trying to assign a value to it in form2, but when I try to run it I get this error message "The name 'x' does not exist in the current context" . I have tried to search in my books and in the help files but i am just missing. I am probably over thinking it but I just can't seem to find it.
|
|
|
|
|
Care to post code snippets? 1 with the variable declaration in form1 and another with the assignment statement in form2.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
form1 varible declaration
public class Form1 : System.Windows.Forms.Form
{
public Form2 Form2= new Form2 ();
public int x = 0;
....
}
form2 assignment statement
private void Form2_Load(object sender, System.EventArgs e)
{
//this is where i think the problem is
x = 3;
}
|
|
|
|
|
Whoa, hold on there. That code looks so...
ok, see, if you want to access a public variable of form 1 in form 2, you an object of form2 must have a reference to an object of form1.
So, the code should be:
public class Form1 : System.Windows.Forms.Form
{
public Form2 Form2= new Form2 (this);
public int x = 0;
....
}
// Form2 class
public class Form2
{
private Form1 owner;
// Constructor
public Form2( Form1 form1)
{
this.owner = form1;
}
private void Form2_Load(object sender, System.EventArgs e)
{
//this is where i know the problem is
owner.x = 3;
}
...
}
with this, the Form1 object's variable x will be set inside Form2 after Form2 loads. Please read up on the concepts of classes and objects.
There has to be more to life than just this
|
|
|
|
|
Although Praveen response is perfectly good, I consider (and he probably also does, reading his comment on the first line) that you should review your design. You are implementing one of the worst design anti-pattern, tight coupling (Re-Coupling). In this design, 2 objects depend on each other. Form1 depends on Form2 which depends on Form1.
You should implement something else, maybe event-base, or interface-based.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Declare an instance of form2, then pass in the variable value to a public method in form2 via a method in form1...
---
public partial class Form1 : Form
{
Form2 form2;
...
private void SendValueToForm2(variableValue)
{
form2.SetValue(variableValue)
}
---
HTH
Jonny
|
|
|
|
|
hi,
I am trying to make my labels transparent in my application for PocketPC.
myLabel.BackColor = Color.Transparent;
does not seem to work.
will appreciate if someone can help.
regards,
rnv
|
|
|
|
|
hi,
i have a c# network based system, in which multiple clients connect to a central server. there is a server application and there are many client applications installed in each of the network workstations.
what i want to do if i disconnect the LAN cable, from the workstation, my server will know it and will prompt the admin for that.
how will do that?? help pls.. tnx..
i have no problem if the client closes the clientApplication, the server workstation list would immediately be updated. but if i disconnect the cable the list is not updated.
|
|
|
|
|
Usually in client-server architecture, the initative must be taken by the client to contact the server. The server does not go searching for the client.
A problem similar to yours is also faced by Web Servers like IIS, which maintain a session per client that connects and session takes up memory on the server. So the session must be destroyed when the client disconnects. But web browsers like IE do not inform the server on being closed. So server comes up with a simple mechanism of destroying the session. If the client does not connect for a long time (maybe 15 minutes), the session gets automatically destroyed.
You can adopt a similar concept. Also, a live client could send some dummy ping messages at regular intervals, to keep the session active.
There has to be more to life than just this
|
|
|
|
|
Thanks for the response... i think ill adopt that method in my client/server application...Thanks again!
|
|
|
|
|
Anyone knows how to get a video frame from the video object mentioned in the title ?
thanks
|
|
|
|
|