|
|
Thanks for the info.
I had come across other example using win32_process, but I felt like it should be easier than this = there should be a method in a .NET class in system.diagnostic that I should be able to use to query for the username of a process.
But, I guess, I could be wrong
Thanks!
Matt Brown
|
|
|
|
|
Hi all
I dont know whether I am asking stupid ques or not but Can anyone advice me about some Insert in windows application.
I have 500000 data to insert in a database.
What will be most efficient way to do it?
Should I use ADO.NET or LINQ or in a proceduse or View....
By your advice I will start my coding
I am a Beginer...
Thanks
|
|
|
|
|
|
Yes Im using SQL Server...
|
|
|
|
|
Then create a stored procedure in you database with the method which was linked to in my previous post.
Then convert you information into an XML format and call the stored procedure with the XML.
Simple...
hmmm pie
|
|
|
|
|
|
I type this same thing over and over in emails to my customers and i was wondering how to write a macro to paste
Please acknowledge receipt of this order by email to me.
into the body of email by hitting a button on the task bar called "Please Acknowledge"
i have visual studio 2008 and using outlook 2007
anyone have any ideas.
Thank you
-Ryan
|
|
|
|
|
|
I'm not a programmer by any measure so I'm turning to you all for help.
I'm creating an InfoPath form which is housing some C# code to run WMI queries when the form is entered. The user will then enter in a few bits of information about them self and submit the form to a SharePoint library to help keep track of our users inventory.
My question is can someone help me clean up this code before i get too far into it? I've been using the WMI Code Creator from Microsoft's Website to get the code samples and by brut force I've gotten them to start to pull the information i'm looking for, but the code seems a little ugly and messy for me. I'm sure there has to be a way to condense some of this code and make it easier to manage and i want to start to figure that out before i get too far, once I see how it's done I should be able to figure it out from there. My code sample just has the video card and the sound card query, but eventually i'll have RAM, Hard drive, CPU, etc.
Code Sample:
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Management;
namespace Inventory_Rev1
{
public partial class FormCode
{
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
ManagementObjectSearcher searcherRAM =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PhysicalMemory");
ManagementObjectSearcher searcherDisplay =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_VideoController");
ManagementObjectSearcher searcherAudio =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_SoundDevice");
ManagementObjectSearcher searcherNIC =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_NetworkAdapter");
foreach (ManagementObject queryObj in searcherAudio.Get())
{
string audioController = queryObj["Name"].ToString();
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode("/my:myFields/my:SoundCard", ns).SetValue(audioController);
}
foreach (ManagementObject queryObj in searcherDisplay.Get())
{
string displayAdapter = queryObj["Name"].ToString();
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode("/my:myFields/my:VideoAdapter", ns).SetValue(displayAdapter);
}
}
}
}
|
|
|
|
|
Is the subject line too long? Probably.
I'm experiencing an issue with my dataset that seems to be telling me that the values for a foreign key in my child table does not exist within the parent table. As far as I can see, the value does exist. This happens when I try to fill a datagridview using a tableadapter.
If the program throws the exception as normal I get the usual "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
If I use a try/catch around the query it fills the datagridview but gives me a red warning sign that reads "ForeignKeyConstraint [ForeignKey] requires the child key values (value) to exist in the parent table."
Has anyone come across this particular issue? Where can I usually find the properties for foreign key contraints?
Any help would be hugely appreciated!
(I'm using the generic Fill query created for tables in sqlserver.)
|
|
|
|
|
Fill the reference table first and then fill the main table. Your error means that the referenfed DataTable does not have data that the maintable is refering to.
Post your code and ill see if i can assist you.
|
|
|
|
|
I came across this error to when I thought the parent value did exist. For me the solution was that I had to make sure that the ParentColumns and ChildColumns for the constraint listed the columns in the same order.
|
|
|
|
|
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if ((e.ColumnIndex == 3) && (e.RowIndex >= 0))
{
Rectangle textRange = new Rectangle(e.ClipBounds.X + 20, e.ClipBounds.Y, e.ClipBounds.Width - 20, e.ClipBounds.Height);
e.PaintBackground(e.ClipBounds, selected);
e.PaintContent(textRange);
e.Handled = true;
}
}
I'm trying to ofset the location of a text string in a winform DataGridView cell, but while the clipbounds parameter of of PaintContent appears like it should let my specify where to paint at, the text is always painted in the default location regardless of what I pass in. Am I doing something wrong with how I'm calling PaintContent , or is it not designed to do what I want? I can use e.Graphics.Drawstring if I have to, but would much prefer to let MS handle all the edge cases for me if possible.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
AFAIK PaintContent acts exactly like Invalidate(aRectangle) . That is, it repaints the rectangular area you pass.
Someone else may know how to do this, but all examples I have ever seen use either DrawString or a TextRenderer .
Sorry not to be of more help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks. It's painting the entire cell area though, not just the part I passed. What your describing would have the 1st char or two of the string not shown in my example (starting at x+20). Seems like it's just retarded/buggy.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I got sort of interested in this, so I've been doing some ferreting around.
Try something like this:
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if ((e.ColumnIndex == 3) && (e.RowIndex >= 0))
{
Rectangle textRange = new Rectangle(e.ClipBounds.X + 20, e.ClipBounds.Y, e.ClipBounds.Width - 20, e.ClipBounds.Height);
e.Paint(textRange,
DataGridViewPaintParts.ContentForeground |
DataGridViewPaintParts.Border |
DataGridViewPaintParts.ErrorIcon |
DataGridViewPaintParts.Focus);
}
}
According to the MSDN page for the DataGridViewCellPaintingEventArgs.Paint method, the Rectangle Parameter is
"A Rectangle that specifies the area of the DataGridView to be painted"
Worth a try?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
That's still left aligning the text with the edge of the cell, not the textrange rectangle. What I'm trying to do is to offset it to the right so that I can draw a small image in the leftmost portion of the cell without covering up the text.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I figured that was what you were trying to do, or at least something like that.
The only way I know that will do that is to use DrawString , or a TextRenderer .
Of course the *ahem* 'correct' way to do this sort of thing is to create your own DataGridViewCell class and include that in your own DataGridViewColumn class. One advantage of that is, of course that it will be available for use in other situations.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: Of course the *ahem* 'correct' way to do this sort of thing is to create your own DataGridViewCell class and include that in your own DataGridViewColumn class. One advantage of that is, of course that it will be available for use in other situations.
True, and I intend to go that route with whatever the text render ends up being; however that was overkill for the proof of concept stage.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I don't know if you have gotten the answer you were looking for since posting, but this should give you what you want.
If you added the columns with the designer you can go to DefaultCellSyle in the column properties. Click the [...] button and change the Padding to the offset you want the cell content to be.
or you can use:
YourDataGridView.Columns[TheColumn].DefaultCellStyle.Padding = new Padding(Left, Top, Right, Bottom);
Inside a custom cell:
this.Style.Padding = new Padding(Left, Top, Right, Bottom);
|
|
|
|
|
I hadn't found this, thanks.
PS what triggered this act of threadcromancy?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Did it work in the way you wanted?
As to how i came upon this:
I had been using the Graphics.DrawString method in a custom DataGridViewTextBoxCell . But i had lost the textbox look and feel when editing the value. After stumbling upon this thread in the search of ways to move the cell content around, i decided to search through the Style Methods of the cell again.
When i saw padding close to the bottom, i had one of those eureka moments. Thinking to myself, "Why would a cell have the need for padding if it didn't have any components to offset from the borders?". The Content of course. Threw some random numbers in and sure enough it offset the cell content.
|
|
|
|
|
It did. I've been working on other stuff and haven't had time to take this from a proof of concept into a custom cell yet. Are there any other gotchas I should be aware of when I do so?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|