|
|
I have a table, Models, in a database. It contains the following fields: ID (auto-generated; unique ID), Model Name (Text), Division (Text). I have a class, AuditRecord, which stores information about each record in another table, Audit Entry. It contains a field which looks values up from the Models table. How should I store a Models record in the AuditRecord class?
I am currently using:
<br />
Dictionary<int, Tuple<string, string>><br />
However, I am not sure this is the most efficient way to go about storing the data. Should I create a class with three properties corresponding to the three fields in the Models table? Or is my current method okay?
|
|
|
|
|
Matt U. wrote: Should I create a class with three properties corresponding to the three fields
in the Models table?
Yes.
|
|
|
|
|
Is the reason about maintainability/readability/encapsulation? Or is there more to it?
|
|
|
|
|
All of that and more.
Plus, not doing so is just lazy; there's no reason not to.
|
|
|
|
|
I figured as much. I'm not entirely sure as to why I didn't create a class to begin with. Thank you for the answer.
One more question: this means I should create classes for similar database objects as well, correct?
|
|
|
|
|
Probably. It depends on what you do with it. Most of the time a DataTable suffices for what I need to do.
|
|
|
|
|
Those and, particularly, extensibility. If you add another field to the table, it's easy to add another one to the class, but it would break all the existing code if it couldn't fit in a Tuple<string,string> any more.
|
|
|
|
|
I need to have one of my properties in a custom control to open the "open file dialogue" window when selected.
I have googled around but it keeps throwing me .net controls!
At present I have a property and when "set" opens the dialogue, but this forces me to enter some text and open it only when deselected...
Just to clarify:
1: Click on the property name in visual studio designer property area
2: it opens the open file dialogue
Thanks
|
|
|
|
|
What you're looking for is a custom PropertyEditor. Read up on it here[^].
|
|
|
|
|
Thanks
|
|
|
|
|
There is a built-in FileNameEditor which you can use as well.
<br />
[EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]<br />
public string FileName<br />
{<br />
get<br />
{<br />
return _FileName;<br />
}<br />
set<br />
{<br />
_FileName = value;<br />
}<br />
}<br />
|
|
|
|
|
Hey guys,
I have a Form1 with a text box in it. When user clicks inside the text box it will pop up Form2 which has a MonthCalendar in it.
Now after the user selects a date and click OK on Form2, i want that selected date string to be displayed in the Form1 text box.
How can i get the Form2 date string to be displayed in Form1 text box?
Thanks in advance.
|
|
|
|
|
The way I do it :
On Form1 I listen for the Form2.FormClosed event like this
Form2 myForm2;
private void textBox1_TextChanged(object sender, EventArgs e)
{
myForm2 = new Form2();
myForm2.FormClosed += new FormClosedEventHandler(myForm2_FormClosed);
myForm2.Show();
}
Then when the event happens :
void myForm2_FormClosed(object sender, FormClosedEventArgs e)
{
this.TextBox1.Text = myForm2.TheDate;
}
On Form2 you need to have a Public property TheDate which you set when they click on your calendar
OnOkClick you just close the form.
hope that makes sense.
|
|
|
|
|
|
Hello Experts,
an application creates an instance of Form1 on startup. During Form1_Load(), an instance of Form2 is created and shown:
private void Form1_Load(object sender, EventArgs e)
{
Form2 form2 = new Form2();
DialogResult dialogResult = form2.ShowDialog(this);
if (dialogResult == DialogResult.Cancel)
{
this.Close();
return;
}
} While user sits in front of his notebook and thinks about pressing "OK" or "Cancel" (both are buttons on form2), there is no icon for Form1 in the taskbar. Neither is there for Form2.
I suppose that Form1's icon is not there because Form1 initialization is not complete at the time form2 is displayed. And Form2 doesn't show an icon since it's modal and leaves taskbar icons to parent. Right?
I'd like to have one icon in the taskbar. Two would be acceptable. How could I achive this?
Ciao,
luker
|
|
|
|
|
All you should need to do is set the ShowInTaskbar property to true in the second form.
|
|
|
|
|
Now this one is weird:
I tried changing ShowInTaskbar without any hope it could help because I had already tried that yesterday in the evening. But I had tried to set it from the calling class. This time I set it in Form2's constructor after InitializeComponent . No luck.
Then I suspected it could relate to Form2 being set to FormBorderStyle = None (Forgot to mention that in the original post, sorry). I tried Sizeable and FixedToolWindow and both lead to the desired result: Icon was present in the taskbar.
But Form2 needs to look exactly like FormBorderStyle = None . So I changed that back and (you're sensing that already, aren't you?) it still works.
What am I supposed to learn herefrom? "If something doesn't work, change a property that could be related to the problem but rather shouldn't get changed. Change it back and hope that it does work now"?
Ciao,
luker
|
|
|
|
|
ShowInTaskbar actually causes the window handle to be recreated, so it has some non-intuitive behaviour. I didn't have any problems with doing in on a FormBorderStyle:None form, but I did have problems trying to change it on a form that was already showing.
|
|
|
|
|
Hi all,
I want to create a setup of my project,i have created on setup and deployment application in which i have included my project and some merge module files.
Setup is build successfully but after running the set up i am getting an error as "The installer has encountered an unexpected error installing this package.This may indicate a problem with this package.The error code is 2705.".
Please any one can u provide me a solution for it.
Thanks in advance.
|
|
|
|
|
sarang_k wrote: Please any one can u provide me a solution for it.
Only you can provide the solution. It's your code, and your setup, so we can't see what's going on there. What I can do though, is tell you how to find out where the problem is.
Instead of launching your MSI from the icon, launch a command shell (cmd.exe) and navigate to the directory containing your MSI. Now type in the following (replacing myinstaller.msi with the name of your msi):
msiexec /i myinstaller.msi /l*v installer_output.txt Once the installer fails, read through the installer output.
|
|
|
|
|
Hello Everybody,
I have some query regarding to find out the location from google map or Images. So I want some help from your site.
Q1 : How to get the Road Area From an Image?
Q2 : Is this any Component to Import the data from AutoCad File and Export to AutoCad File.
Q3 : Is this any component for Window Based Control for Get the control from ArcGis.
Q4 : How Can i convert the Road to Line Form?
Your suggestions and help is required.
Thanks
If you can think then I Can.
|
|
|
|
|
Before anybody could offer any help, you might want to explain what you are trying to achieve so we can offer you some alternatives. There are no easy ways to extract roads from images because roads are not 2 dimensional items - they are represented internally as having X, Y and Z axes.
As far as the conversion of AutoCAD data, you need to specify what you are trying to convert it into/from. If it's a well known type, it might be supported by OGR which has a .NET version here[^].
|
|
|
|
|
Based on the assumption that you do GIS project.
Q1: normally, the road name for GIS project does not from image, it is from vector map data, the map data format could be shape file (.shp) or some other format. If you really want to get the road name from image, you need do image processing.
Q3: ArcGIS has a development SDK and you can uses in windows application, it supports C++, C# and so on. You can check on ESRI website.
Q4: If you have map data and in vector format, you don't need convert to line and you just read from the file. If you want to exact the road from a image, then again, you have to use image processing.
Hope it help.
From Athena Solution (www.athena-solution.com)
|
|
|
|
|
So Today I was going trough some old projects of mine and found a project i tried to make a couple of years ago. It's a client for any flash game on the web. But the problem I have with it is that i never was able to find out how to record something that happend in the form. I am asking your help because I really want to finish this project so that I can make movies of some of the flash games I play and I dont feel like use camtasia or something.
I am not asking for you guys to write my code but some help in the right direction may be helpful
Kind regards
Yves Cambré
|
|
|
|