|
+5 An interesting example, and nice to see an example where it's all done without XAML !
thanks, Bill
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|
|
|
That's very cool, Gerry!
I'd like to try implementing this both ways, but the XAML crap is more overhead than I have time to deal with right now, though I can certainly see some excellent uses for it - someday...
Thanks for the sampler!
Will Rogers never met me.
|
|
|
|
|
I'm importing and updating a parts table from a CSV file into a table using Linq To Sql:
public int ImportPartsFile(string FileName)
{
using (SparesDataContext dc = getDataContext())
{
using (TextFieldParser tfp = new TextFieldParser(FileName))
{
int lineNo = 0;
int imported = 0;
int updated = 0;
tfp.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
tfp.SetDelimiters(",");
string[] words;
while (!tfp.EndOfData)
{
words = tfp.ReadFields();
lineNo++;
string partNo = words[0];
string description = words[1];
string priceString = words[2];
if (partNo.Trim() == string.Empty || priceString == string.Empty)
{
continue;
}
priceString = priceString.Replace("$", "");
int price = Convert.ToInt32(Convert.ToDecimal(priceString));
var part = (from p in dc.tblHPParts
where p.PartNumber.Trim().ToLower() == partNo.Trim().ToLower()
select p).FirstOrDefault();
if (part == null)
{
tblHPPart partRow = new tblHPPart
{
PartNumber = partNo,
Description = description,
Price = price
};
dc.tblHPParts.InsertOnSubmit(partRow);
dc.SubmitChanges();
imported++;
}
else
{
part.Price = price;
dc.SubmitChanges();
updated++;
}
}
return imported;
}
}
}
At the point where I do
else
{
part.Price = price;
dc.SubmitChanges();
updated++;
}
if get
Row not found or changed
There are 3676 lines in the CSV file, and it dies on line 40
022N02177 ,XEROX PICKUP ROLLER ,$13
Anyone know what's wrong?
If it's not broken, fix it until it is
|
|
|
|
|
As observed in the data of line 40 given above in 022N02177 0 is zero instead of letter 'O' . But if that is the case and the part number is not found then the execution should go in to the if (part == null) block. But I want to share what I have noticed and please see whether the issue is because of that.
|
|
|
|
|
546461231
modified 17-May-12 15:24pm.
|
|
|
|
|
If you are writing for a real bookstore, you're going to need a database. There are several excellent free ones, and I can recommend SQL Server Express for your use. You have some basic requirements, you need to flesh them out - what attributes does the book need? Do you need to implement security for the application? Where are the categories going to come from? Do you need to hook up to a barcode scanner of some sort?
Good luck. I always enjoy this phase of the project.
|
|
|
|
|
HI! IT SHOULD GET AND SAVE FROM AN .TXT FILE
IF U GOT AN EMAIL I COULD MAYBE SEND IT TO YOU SO U CAN LOOK IF U WANT?
|
|
|
|
|
So this is for homework?
I don't give out my email address unless I know the person well. I used to have it enabled here on the site, but I ended up receiving between 10 to 20 requests for help a day. I have a company to run and a homelife to try and maintain, I don't have time to do anyone else's work for them.
If you have a problem with a particular piece of code, show us the parts of your code you are stuck on. Also, don't use all capitals in a post - it's considered bad form on the internet, and please don't use text speak as it's not very professional. I'm in the well over 30 year old group of people who really don't like text speak.
|
|
|
|
|
So a bad subject line, upper-case shouting, textspeak, gimme code, asking for an e-mail address, and modifying/removing earlier posts is your best attempt to get some help here? I don't think so. You violated about every rule of this web site (see "How to get an answer to your question").
|
|
|
|
|
You do...
You do indeed.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
I was trying to determine on how to get this to work.
When clicking on either up or down, its already set to 0.1 increment/decrement value.
However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement.
I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change.
What's the effective way to get the step value to change upon the shift-click is detected?
|
|
|
|
|
Create your own class, derived from NumericUpDown. Override the UpButton and DownButton methods:
public class MyUpDown : NumericUpDown
{
public override void UpButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.UpButton();
Increment = save;
}
public override void DownButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.DownButton();
Increment = save;
}
}
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
In the C# Visual Studio 2010 project I am working on, I cannot edit or add a path to a referece file. I have inherited a project at work. When I open the project and go to the references scetion in the Visual Studio 2010 IDE there are some little yellow warning signs showing that there is something amiss with the reference listed there.
But when I click on the item and look at the missing path, I find that the name "Path" is in grey suggesting that I cannot edit it and, sure enough, I cannot add the path name to the adjoining field. What causes this? I have the solution file and the project file checked out in edit mode.
When I open the project file, the error list also gives the warnings for each missing reference:
"The reference component '(the file name)' cound not be found"
Well, I know where they are but editing the path to point there is the problem.
|
|
|
|
|
Try deleting them from the project and then adding them in again using the actual location.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
That probably would have worked.
A Project file is an XML file.
We found that the project file had a hand-coded reference that was wrong.
|
|
|
|
|
The project file had a hand-coded reference that was wrong.
|
|
|
|
|
Hi,
Can I use a user control as a base class to write some
user control variations. I have a user control with a panel. I would like to create another user control based on the first, but with some controls in that panel. How can I do this using the designer ?
tia
|
|
|
|
|
You certainly can:
class ExtendedUserControl : MyUserControl {
}
I've no idea if you can create one in the designer but you can certainly design one once it exists (a previous project of mine was full of these).
Take note though that if MyUserControl is abstract, VS's designer throws a fit and refuses to design it (not sure if this is also true in e.g. SharpDevelop). That can be very annoying.
|
|
|
|
|
Hi,
Now I do :
public partial class PricePanelBase : UserControl
{
public PricePanelBase()
{
InitializeComponent();
InstallControls();
}
protected virtual void GetControls(ControlCollection Ctrls)
{
}
private int InstallControls()
{
ControlCollection Ctrls = new ControlCollection(CPanel);
GetControls(Ctrls);
foreach (Control Ctrl in Ctrls)
CPanel.Controls.Add(Ctrl);
return Ctrls.Count;
} ...
public partial class PricePanel : PricePanelBase
{
public PricePanel()
{
InitializeComponent();
}
protected override void GetControls(ControlCollection Ctrls)
{
DataGridView GrdVw = new DataGridView();
GrdVw.Name = "dataGridView1";
GrdVw.Location = new Point(3, 35);
GrdVw.Size = new Size(438, 146);
Ctrls.Add(GrdVw);
}...
When I drag the PricePanel control in a form I get an ArgumentException:
'Child' is not a child control of this parent.
and the control doesn't get drawn.
|
|
|
|
|
Inheritance is a great thing but I strongly recommend against inheriting from custom user controls in winforms. It gets very ugly, very quickly.
"You get that on the big jobs."
|
|
|
|
|
Hi
Good morning. My query is,i have Some application. In that application i have some one sub directory. In that directory i have 3 jpg files. i want to read those files from directoiry and i need to store the Image file name, Image bytes into data base. Once completion of reading files from the directory i need to delete those files.Can any one sunggest me how to approach that.
|
|
|
|
|
I can tell you that this is a install-time problem, not run-time.
The database should be populated with this information when the application is installed. If you're going to delete the image files, why are you even adding them to the app?? Just populate the database with the data at install-time.
Why? Because a normal user cannot modify anything under Program Files. When someone launches an app, the app inherits the security token of the user (the app runs AS the user who launched it). Normal users do not have Write or Modify permissions to anything under Program Files.
|
|
|
|
|
Just write code for each of the steps you outlined. Storing byte arrays in a database is the topic of many articles. Come back here if you have a specific question.
|
|
|
|
|
Hello everybody, I have an issue about GDI objects.
Whenever the form close and then reload the no of GDI objects is increasing continously in task manager. Although objects of form is disposed on every form closing time but it is increasing. How I can dispose all those objects which are not disposing.
|
|
|
|