|
Have a look at this : [^]
A dogged, arrogant belief in self and the childlike idealism that comes with not knowing my limits. This is my greatest blessing, my priceless attribute.
|
|
|
|
|
...I was actually hoping that there was a solution that didn't involve reflection. I mentioned that in my original post, but edited it out to keep the suggestions open.
I mean, you can get the string representation of an enum with the following:
[Enum].GetName(typeof([LIB].Enumerations.InspectionStatusType), Me._inspection.Status)
(and that is in the mscorlib.)
Isn't there any way to retrieve the string evaluation of an object's property without reflection yet?
"I need build Skynet. Plz send code"
|
|
|
|
|
Enum.GetName uses reflection internally. Reflection IS the retrieval of code metadata...which includes the name of a property. Thats the entire purpose of reflection...
|
|
|
|
|
Jon Rista wrote: Enum.GetName uses reflection internally
ah, good to know. Thanks
"I need build Skynet. Plz send code"
|
|
|
|
|
i will tell the requirement in detail.
i have spooled some record in one datatable, in score.cs class.
i have to print that report in other windows form name report.cs(which is a windows form where i kept my crystal report viewer)
now i want to access my datatable in the score.cs.
for this i have to inherit those things.
like public partial class report:score,
instead of public partial class report:form,
but if i do so i m getting error that my form is not showing,as form is a class we cannot remove that.
can you please guide me how to access my datatable??
|
|
|
|
|
Well this site is an excellent database in itself of some very useful articles pertaining to connecting to databases programmatically, give CodeProject a search or two
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hello Fellow Coders;
I'm still struggling with some of the concepts of the treeview in C#. I found this code whick works great. I am trying to figure out how to assign values to the nodes that get added such as the name, text,tag, imageindex, tooltip etc.
This sample is using the TreeNodeCollection can I assign the above properties using this collection??
Here is the code....
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
foreach (TreeNode node in Parent)
{
if (node.Text == text)
return node;
}
return Parent.Add(text);
}
void InsertNodes(TreeNodeCollection treeviewNodes, List<string> _nodes)
{
if (_nodes.Count == 0)
return; //Recursive exit
TreeNode TempNode = AddNode(treeviewNodes, _nodes[0]);
_nodes.RemoveAt(0);
InsertNodes(TempNode.Nodes, _nodes); //Recursive calling
}
private void button1_Click(object sender, EventArgs e)
{
List<string> NODES = new List<string>(); //Save nodes
string[] strArr = textBox1.Text.Split('\\');
foreach (string str in strArr)
NODES.Add(str);
InsertNodes(treeView1.Nodes, NODES);
}
Thanks In Advance
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Please use pre tags for code blocks. It makes the reading easier.
The first method return the node added so you can use it's properties on the calling side:
...
TreeNode addedNode = AddNode(MyTreeView.Nodes, "New node text");
addedNode.Tag = "XYZ";
addedNode.ImageIndex = 123;
...
Or if you want, add a variable inside the method and assign the properties you want in the method:
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
TreeNode temporaryNode;
foreach (TreeNode node in Parent)
{
if (node.Text == text)
return node;
}
temporaryNode = Parent.Add(text);
temporaryNode.Tag = "XYZ";
temporaryNode.ImageIndex = 123;
...
return temporaryNode;
}
The same idea goes with the other method.
In all cases you may have to add parameters to the methods or extra logic how you decide what tag, imageindex etc is set.
This is quite basics, so I think you should get a good book concerning C# programming.
|
|
|
|
|
Thanks for this answer...I will try it out.
I have read
Visual C#.Net by Williams MS Press
And currently reading
Programming Visual C# 2008 by Marshall MS Press
Can you recommend a book??
Thanks
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
|
Thanks;
I had tried your suggestion before asking the questions but in looking at your reply realized that I was doing it in the wrong place.
Here is what worked..
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
TreeNode temporaryNode;
foreach (TreeNode node in Parent)
{
if (node.Text == text)
{
return node;
}
}
temporaryNode = Parent.Add(text);
temporaryNode.Name = text;
temporaryNode.Text = text;
temporaryNode.Tag = "XYZ";
temporaryNode.ToolTipText = "XYZ";
temporaryNode.ImageIndex = 123;
temporaryNode.SelectedImageIndex = 123;
return temporaryNode;
//
return Parent.Add(text);
}
Thanks Again
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Glad if it helped
|
|
|
|
|
As a followup for anyone reading this. This part of the above code has unexpected results.....
temporaryNode = Parent.Add(text);
temporaryNode.Name = text;
temporaryNode.Text = text;
temporaryNode.Tag = "XYZ";
temporaryNode.ToolTipText = "XYZ";
temporaryNode.ImageIndex = 123;
temporaryNode.SelectedImageIndex = 123;
return temporaryNode;
But on the whole if you are looking for a recursive way to add tree nodes the orginally posted code works great. It's just not full featured.
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Hi experts.
I wanna create a Win App that needs a simple database, just for saving plain text and plain numbers.
Now i don't know which one is better ! sdf Database , or mdf database or XML.
What's your suggest ?
Could u guide me ?
Thank you.
|
|
|
|
|
|
What about SQLite? It's also used by Firefox 3 for storing passwords and other data.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This is really a matter of opinion, so here's mine:
- for single user application with small amount of local data => SQL Server Compact Edition
- for multi user application with medium amount of shared data => SQL Server Express / Oracle XE
- for multi user application with large amount of shared data => SQL Server Std or Enterprise / Oracle 11g
I believe that the next question you would have is: what is a small or large amount of data. Again a matter of opinion but perhaps some quantities (these are certainly not accurate but give some idea):
- small amount could be less than 1 GB, perhaps less than a hundred tables and no table contain over 10 000 rows
- large amount could be more than 4 GB of actual data, perhaps 500+ tables tables and and some tables contain over 10 000 000 rows. User amount is high, let's say over 1000 concurrent.
I already regret that I wrote any quantítative information since it's really not that simple (also consider licensing, support level, activity levels, transaction counts etc.) but I'm prepared to get flamed
|
|
|
|
|
|
You're welcome
|
|
|
|
|
Hi All,
Can anybody help me in creating ComboBox in Datagrid for a Windows application. If possible pls. provide me a small code snippet.
Thanks,
Abdul Aleem.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
You want code snippet.
OK. Here is a code snippet.
if (knowledge < 0)
{
MessageBox.Show("Google is my friend");
}
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
It's all done in the designer. Drop in the Datagridview, edit the Columns collection in the properties view, set the ColumnType to DataGridViewComboBoxColumn, then edit the Items collection.
You can also set the combobox items in code or use a datasource to fill the combo box.
SS => Qualified in Submarines
"We sleep soundly in our beds because rough men stand ready in the night to visit violence on those who would do us harm". Winston Churchill
|
|
|
|
|
At our software company, we use Vista x64 machines for programming.
We have a network share where we put some of our dll's for 'global' usage.
The permissions on this network share are set to: 'Everyone Full Control' and 'Security: Domain Users Full Control'.
In our Visual Studio Team System 2008 IDE we CAN reference the dll's in all our assemblies.
BUT, when we create a Test Project with Unit Test classes, and we reference the dll's on this share, we get the following error when we start the test runs:
Failed to queue test run 'xxxxx': Test Run deployment issue: The location of the file or directory '\\xxxxx\Binaries\xxxxx.xxx.dll' is not trusted.
On all the websites I found with this error message, the solution is:
for x86
c:\Windows\Microsoft.NET\Framework\v2.0.50727\CasPol -m -ag 1.2 -url \\xxxxx\Binaries\* FullTrust
for x64
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\CasPol -m -ag 1.2 -url \\xxxxx\Binaries\* FullTrust
But this does not work.
I downloaded the SDK, and tried to do the same with the .NET Framework 2.0 Configuration wizard.
>> Console Root >> .NET Framework 2.0 Configuration >> My Computer >> Runtime Securyti Policy >> Machine >> Code Groups >> All_Code >> New >> Name: xxx, Description xxx >> Type: URL: \\xxxxx\Binaries\* >> FullTrust
But still nothing is trusted....
I even set (on the server) >> System Properties >> Advanced >> Performance Settings >> Data Execution Prevention >> Turn on DEP for essential Windows programs and services only (that's how desperate we are).
|
|
|
|
|
Good Afternoon All
i have the Following code that retrieve the file names from the Certain Directory and bind it to the Dropdownlist. like this
DirectoryInfo dir = new DirectoryInfo(@"C:\DATABASES\");
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
cmbrestore.Items.Add(Convert.ToString(file));
}
The code is working, but now if there is a File with same name , it will display them all.
How can i make sure that it will show the File names Distinctively ?
How can i exclude certain File extension from being displayed from the Dropdownlist ?
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
Vuyiswa Maseko wrote: The code is working, but now if there is a File with same name , it will display them all.
You can't have two files with the same name in the same directory so, if you are just adding from one directory, this isn't a problem.
Vuyiswa Maseko wrote: How can i exclude certain File extension from being displayed from the Dropdownlist ?
Before you call Items.Add, check the file extension. One way to do this would be:
if (Path.GetExtension(file.FullName) != ".cs")
{
cmbRestore.Items.Add(file.Name);
}
|
|
|
|