|
I have a Windows Forms application that requires to read an XML, i know you can put something like
<add key="serverPath" value="http://localhost/something.aspx">
but in the case the value is XML what can I do? i tried to put the xml inside the value but it didnt work
<add key="test" value="<hi>">
i had to do it this way
<add key="test" value="<hi>">
that worked, but it would be too hard for the user to edit and not make mistakes when the XML grows, so i was wondering if there is any way I could just put my xml tags somewhere in the .config file where it doesn't make the application crash
something like this
<configuration>
<appsettings>
<add key="serverPath" value="http://localhost">
<mytag>
<moretags>blah
I basically want to avoid that some settings are stored in the .config file and others in a different XML file
Thanks in advance
|
|
|
|
|
I have a Windows Forms application that requires to read an XML, i know you can put something like
< add key="serverPath" value="http://localhost/something.aspx" / >
but in the case the value is XML what can I do? i tried to put the xml inside the value but it didnt work
< add key="test" value="< hi >" / >
i had to do it this way
< add key="test" value="<hi>" / >
that worked, but it would be too hard for the user to edit and not make mistakes when the XML grows, so i was wondering if there is any way I could just put my xml tags somewhere in the .config file where it doesn't make the application crash
something like this
< configuration >
< appSettings >
< add key="serverPath" value="http://localhost" / >
< /appSettings >
< myTag >
< moreTags > blah < /moreTags >
< /myTag >
< /configuration >
I basically want to avoid that some settings are stored in the .config file and others in a different XML file
Thanks in advance
|
|
|
|
|
this is getting complicated to post
when i wrote "i had to do it this way" and the sentence looks identical i wrote
& lt; hi & gt;
the question at the end is can i add my own tags to the .config file?
Thanks
|
|
|
|
|
Damn the board did it to me too.
<configsections>
<customsettings>
<add key="x" value="y">
Reading your custom section
GetConfig("customsettings")("x")
Hope this helps
He who laughs last thinks slowest.
|
|
|
|
|
Damn the board did it to me too.
<configSections>
<section name="customSettings"/>
</configSections>
<customSettings>
<add key="x" value="y" />
</customSettings>
Reading your custom section
GetConfig("customsettings")("x")
He who laughs last thinks slowest.
|
|
|
|
|
I have a menu which I have to owner draw the few menu items which contain icons. I snagged the code to do this from Petzold's Prgramming Windows in C# book. It helped a lot, but one thing that bothers me is the hardcoded font size and unknown style.
It comes up looking odd because the font is slightly different than the rest of the context menu.
I need to to find two items.
1. Default system font and font size for menu items.
2. Background color
Default size and font to match font itself. Is there something like SystemColors class that I can get into for the proper font style adn size for menu items.
When 2 is discovered, how do I changed the background color of the drawn menu item rectangle? It looks fine on my machine which is XP and the background is white already. When I ran my proggy on Win2K, the regular items had the standard silver/gray background, but my owner drawn items have a white background. Yuck!
Example of my current owner drawn menu items (measure and draw) are below for reference.
<code>
<COLOR=008000>
</COLOR><COLOR=0000ff>private void </COLOR><COLOR=800080>MeasureItemAddSmileyMenuItem</COLOR>(<COLOR=0000ff>object </COLOR><COLOR=800080>obj</COLOR>, <COLOR=800080>MeasureItemEventArgs miea</COLOR>)
{
<COLOR=0000ff>int </COLOR><COLOR=800080>iFontPointSize </COLOR><COLOR=008000>= </COLOR><COLOR=ff0000>10</COLOR>;
<COLOR=800080>MenuItem mi </COLOR><COLOR=008000>= </COLOR>(<COLOR=800080>MenuItem</COLOR>)<COLOR=800080>obj</COLOR>;
<COLOR=800080>Font ItemFont </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>Font</COLOR>(<COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Text</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Substring</COLOR>(<COLOR=ff0000>1</COLOR>), <COLOR=800080>iFontPointSize</COLOR>);
<COLOR=800080>StringFormat strfmt </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>StringFormat</COLOR>();
<COLOR=800080>SizeF sizef </COLOR><COLOR=008000>= </COLOR><COLOR=800080>miea</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>MeasureString</COLOR>(<COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Text</COLOR>, <COLOR=800080>ItemFont</COLOR>, <COLOR=ff0000>1000</COLOR>, <COLOR=800080>strfmt</COLOR>);
<COLOR=800080>CSmilies oSmile </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>CSmilies</COLOR>(<COLOR=ff0000>2</COLOR>);
<COLOR=800080>Bitmap bmSmiley </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>Bitmap</COLOR>(<COLOR=0000ff>typeof</COLOR>(<COLOR=800080>vBCodeGenForm</COLOR>),<COLOR=800080>oSmile</COLOR><COLOR=008000>.</COLOR><COLOR=800080>SmileyIconFileName</COLOR>);
<COLOR=800080>miea</COLOR><COLOR=008000>.</COLOR><COLOR=800080>ItemWidth </COLOR><COLOR=008000>= </COLOR>(<COLOR=0000ff>int</COLOR>)<COLOR=800080>Math</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Ceiling</COLOR>(<COLOR=800080>sizef</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>) <COLOR=008000>+ </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>;
<COLOR=800080>miea</COLOR><COLOR=008000>.</COLOR><COLOR=800080>ItemHeight </COLOR><COLOR=008000>= </COLOR>(<COLOR=0000ff>int</COLOR>)<COLOR=800080>Math</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Ceiling</COLOR>(<COLOR=800080>sizef</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height</COLOR>) <COLOR=008000>+ </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height</COLOR>;
}
<COLOR=0000ff>private void </COLOR><COLOR=800080>DrawmenuItemSmiley1</COLOR>(<COLOR=0000ff>object </COLOR><COLOR=800080>sender</COLOR>, <COLOR=800080>System</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Windows</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Forms</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawItemEventArgs e</COLOR>)
{
<COLOR=0000ff>int </COLOR><COLOR=800080>iFontPointSize </COLOR><COLOR=008000>= </COLOR><COLOR=ff0000>10</COLOR>;
<COLOR=800080>MenuItem mi </COLOR><COLOR=008000>= </COLOR>(<COLOR=800080>MenuItem</COLOR>)<COLOR=800080>sender</COLOR>;
<COLOR=800080>Font ItemFont </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>Font</COLOR>(<COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Text</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Substring</COLOR>(<COLOR=ff0000>1</COLOR>), <COLOR=800080>iFontPointSize</COLOR>);
<COLOR=800080>Brush brush</COLOR>;
<COLOR=800080>StringFormat strfmt </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>StringFormat</COLOR>();
<COLOR=008000>
</COLOR><COLOR=800080>strfmt</COLOR><COLOR=008000>.</COLOR><COLOR=800080>LineAlignment </COLOR><COLOR=008000>= </COLOR><COLOR=800080>System</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Drawing</COLOR><COLOR=008000>.</COLOR><COLOR=800080>StringAlignment</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Center</COLOR>;
<COLOR=800080>CSmilies oSmile </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>CSmilies</COLOR>(<COLOR=ff0000>0</COLOR>);
<COLOR=800080>Bitmap bmSmiley </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>Bitmap</COLOR>(<COLOR=0000ff>typeof</COLOR>(<COLOR=800080>vBCodeGenForm</COLOR>),<COLOR=800080>oSmile</COLOR><COLOR=008000>.</COLOR><COLOR=800080>SmileyIconFileName</COLOR>);
<COLOR=008000>
</COLOR><COLOR=800080>Rectangle rectImage </COLOR><COLOR=008000>= </COLOR><COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>;
<COLOR=008000>
</COLOR><COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width </COLOR><COLOR=008000>= </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>;
<COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height </COLOR><COLOR=008000>= </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height</COLOR>;
<COLOR=800080>Rectangle rectText </COLOR><COLOR=008000>= </COLOR><COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>;
<COLOR=800080>rectText</COLOR><COLOR=008000>.</COLOR><COLOR=800080>X </COLOR><COLOR=008000>+= </COLOR><COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>;
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawBackground</COLOR>();
<COLOR=0000ff>if </COLOR>( (<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>State </COLOR><COLOR=008000>& </COLOR><COLOR=800080>DrawItemState</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Selected</COLOR>) <COLOR=008000>!= </COLOR><COLOR=ff0000>0</COLOR>)
{
<COLOR=800080>brush </COLOR><COLOR=008000>= </COLOR><COLOR=800080>SystemBrushes</COLOR><COLOR=008000>.</COLOR><COLOR=800080>HighlightText</COLOR>;
}
<COLOR=0000ff>else
</COLOR>{
<COLOR=800080>brush </COLOR><COLOR=008000>= </COLOR><COLOR=800080>SystemBrushes</COLOR><COLOR=008000>.</COLOR><COLOR=800080>FromSystemColor</COLOR>(<COLOR=800080>SystemColors</COLOR><COLOR=008000>.</COLOR><COLOR=800080>MenuText</COLOR>);
}
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawImage</COLOR>(<COLOR=800080>bmSmiley</COLOR>, <COLOR=800080>rectImage</COLOR>);
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawString</COLOR>(<COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Text</COLOR>, <COLOR=800080>ItemFont</COLOR>, <COLOR=800080>brush</COLOR>, <COLOR=800080>rectText</COLOR>, <COLOR=800080>strfmt</COLOR>);
}
</code>
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Nobody seemed to know, but I was able to figure it out with a little help from this article right here at Code Project:
<url>http://www.codeproject.com/cs/menu/MenuImage.asp
I am reposting my DrawItem as it is now to show the correct way to do so in case anyone else runs into the same question.
<br />
<COLOR=008000>
</COLOR><COLOR=0000ff>private void </COLOR><COLOR=800080>DrawAddSmileyMenuItem</COLOR>(<COLOR=0000ff>object </COLOR><COLOR=800080>sender</COLOR>, <COLOR=800080>System</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Windows</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Forms</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawItemEventArgs e</COLOR>)<br />
{<br />
<COLOR=800080>MenuItem mi </COLOR><COLOR=008000>= </COLOR>(<COLOR=800080>MenuItem</COLOR>)<COLOR=800080>sender</COLOR>;<br />
<br />
<COLOR=008000>
</COLOR><COLOR=800080>Font menuFont </COLOR><COLOR=008000>= </COLOR><COLOR=800080>SystemInformation</COLOR><COLOR=008000>.</COLOR><COLOR=800080>MenuFont </COLOR>;<br />
<COLOR=800080>SolidBrush menuBrush </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>null </COLOR>;<br />
<br />
<COLOR=008000>
</COLOR><COLOR=0000ff>if </COLOR>( <COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Enabled </COLOR><COLOR=008000>== </COLOR><COLOR=0000ff>false </COLOR>)<br />
{<br />
<COLOR=008000>
</COLOR><COLOR=800080>menuBrush </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>SolidBrush</COLOR>( <COLOR=800080>SystemColors</COLOR><COLOR=008000>.</COLOR><COLOR=800080>GrayText </COLOR>) ;<br />
}<br />
<COLOR=0000ff>else<br />
</COLOR>{<br />
<COLOR=0000ff>if </COLOR>( (<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>State </COLOR><COLOR=008000>& </COLOR><COLOR=800080>DrawItemState</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Selected</COLOR>) <COLOR=008000>!= </COLOR><COLOR=ff0000>0</COLOR>)<br />
{<br />
<COLOR=008000>
</COLOR><COLOR=800080>menuBrush </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>SolidBrush</COLOR>( <COLOR=800080>SystemColors</COLOR><COLOR=008000>.</COLOR><COLOR=800080>HighlightText </COLOR>) ;<br />
}<br />
<COLOR=0000ff>else<br />
</COLOR>{<br />
<COLOR=008000>
</COLOR><COLOR=800080>menuBrush </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>SolidBrush</COLOR>( <COLOR=800080>SystemColors</COLOR><COLOR=008000>.</COLOR><COLOR=800080>MenuText </COLOR>) ;<br />
}<br />
}<br />
<br />
<COLOR=008000>
</COLOR><COLOR=800080>StringFormat strfmt </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>StringFormat</COLOR>();<br />
<COLOR=800080>strfmt</COLOR><COLOR=008000>.</COLOR><COLOR=800080>LineAlignment </COLOR><COLOR=008000>= </COLOR><COLOR=800080>System</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Drawing</COLOR><COLOR=008000>.</COLOR><COLOR=800080>StringAlignment</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Center</COLOR>;<br />
<br />
<COLOR=008000>
</COLOR><COLOR=800080>CSmilies oSmile </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>CSmilies</COLOR>(<COLOR=ff0000>2</COLOR>);<br />
<COLOR=800080>Bitmap bmSmiley </COLOR><COLOR=008000>= </COLOR><COLOR=0000ff>new </COLOR><COLOR=800080>Bitmap</COLOR>(<COLOR=0000ff>typeof</COLOR>(<COLOR=800080>vBCodeGenForm</COLOR>),<COLOR=800080>oSmile</COLOR><COLOR=008000>.</COLOR><COLOR=800080>SmileyIconFileName</COLOR>);<br />
<br />
<COLOR=008000>
</COLOR><COLOR=800080>Rectangle rectImage </COLOR><COLOR=008000>= </COLOR><COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>;<br />
<br />
<COLOR=008000>
</COLOR><COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width </COLOR><COLOR=008000>= </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>;<br />
<COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height </COLOR><COLOR=008000>= </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height</COLOR>;<br />
<COLOR=800080>Rectangle rectText </COLOR><COLOR=008000>= </COLOR><COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>;<br />
<COLOR=800080>rectText</COLOR><COLOR=008000>.</COLOR><COLOR=800080>X </COLOR><COLOR=008000>+= </COLOR><COLOR=800080>rectImage</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>;<br />
<br />
<COLOR=008000>
<br />
</COLOR><COLOR=0000ff>if </COLOR>( (<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>State </COLOR><COLOR=008000>& </COLOR><COLOR=800080>DrawItemState</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Selected</COLOR>) <COLOR=008000>!= </COLOR><COLOR=ff0000>0</COLOR>)<br />
{<br />
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>FillRectangle</COLOR>(<COLOR=800080>SystemBrushes</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Highlight</COLOR>, <COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>); }<br />
<COLOR=0000ff>else<br />
</COLOR>{<br />
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>FillRectangle</COLOR>(<COLOR=800080>SystemBrushes</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Menu</COLOR>, <COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR>); <br />
}<br />
<br />
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawImage</COLOR>(<COLOR=800080>bmSmiley</COLOR>, <COLOR=800080>rectImage</COLOR>);<br />
<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Graphics</COLOR><COLOR=008000>.</COLOR><COLOR=800080>DrawString</COLOR>( <COLOR=800080>mi</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Text</COLOR>, <COLOR=800080>menuFont</COLOR>, <COLOR=800080>menuBrush</COLOR>, <COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Left </COLOR><COLOR=008000>+ </COLOR><COLOR=800080>bmSmiley</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Width</COLOR>, <COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Top </COLOR><COLOR=008000>+ </COLOR>((<COLOR=800080>e</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Bounds</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height </COLOR><COLOR=008000>- </COLOR><COLOR=800080>menuFont</COLOR><COLOR=008000>.</COLOR><COLOR=800080>Height</COLOR>) <COLOR=008000>/ </COLOR><COLOR=ff0000>2</COLOR>), <COLOR=800080>strfmt </COLOR>) ;<br />
}<br />
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Hi there,
I have partitioned my hard drive and loaded my visula studion.net in D: drive. I have created a virtual directory, ASP.NET and mapped it to D:/asp.net .When I was trying to compile a small c# application using csc.exe at the command prompt(csc FirstApp.cs) its popping up the following error message.
'csc' is not recognized as an internal or external command,
operable program or batch file.
I guess its coz' the path isn't set up. But i don't know how do i set the path for c# compiler. Please help me some one.
thanks in advance
dev
|
|
|
|
|
Start/Program Files/Microsoft Visual Studio.NET/Visual Studio.NET Tools/Visual Studio.NET Command Prompt.
I suggest you to copy this shortcut to a shorter path
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
HI Daniel,
I got it thanks for the help. I am sure many a doubts would raise if i move further deep into the subject... I think i can learn much from here. I really appreciate all people like you
thanks
dev
|
|
|
|
|
I want to write a subroutine which fetches data from a database, save column to a hashtable (columname=columnvalue) and then put each dataset hashtable into an array ... then i want to return this array to the main program and run through each element and dereference the element back to a hashtable ... in perl i know how to do this - but have no clue how this had to be writen in c# ... (perl: %hash = %$array[element])
i trie something to put a hashtable into an array of string[] but i don't know how to get the hash back from the element of the string[] ...
Thanks for your help!
Matthias
|
|
|
|
|
This may seem obvious, but have you tried System.Collections.Hastable? If you are working with only strings, the System.Collections.Specialized.NameValueCollection may offer better performance..
|
|
|
|
|
HashTable[] ha = new HashTable[number_of_elements_in_array]();<br />
<br />
HashTable h = new HashTable();<br />
h.Add(key, value);<br />
<br />
ha[array_element_number] = h;<br />
Now you pass your ha array around, and get the hashtables back like this:
<br />
HashTable h = ha[array_element_number];<br />
If you defined your array in another way, like object[] or so, you will have to do a cast when retrieving the hashtable.
|
|
|
|
|
Thanks Arjan - works fine!
|
|
|
|
|
Sounds like your trying to apply Perl design to a C# program. Before you go too far, you should first try to understand the database access classes in the System.Data namespace. A DataTable acts a lot like an array of DataRows, where individual fields can be accessed by name.
But if you really want something like a perl array of hashes, it might look like this:
using System.Collections;
...
ArrayList a = new ArrayList();
Hashtable h = new Hashtable();
h.Add( "One", 1 );
h.Add( "Two", 2 );
a.Add( h );
h = (Hashtable)a[0];
Console.WriteLine( h["One"] );
Burt Harris
|
|
|
|
|
I have a Form with a toolbar. The toolbar contains some Buttons with Text like "&New", "&Edit", ...
I meant that marking the Buttons as HotKey is enough to allow access via ALT+"N", ALT+"E", ...to fire the ClickEvent.
So how is it possible that Toolbar Buttons react on Keyboard Inputs like normal Buttons with HotKey?
Thanks
Stefan
|
|
|
|
|
I want to write a LinkList Libary use "Template", but I must write in C# and C# doesn't have "Template"! How do I do? or How can I do? thx!
|
|
|
|
|
No, but it will do, maybe in the next release.
As an aside while they are called templates in C++, they will probably be refered to as Generics in other languages e.g. Java - which has just had them added in 1.5.
As for LinkList, have a look at the .NET collections classes under "System.Collections".
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Since we have to wait for Whidbey (.NET 2) for true Generics to be implemented, I read an interesting article on GotDotNet.com about using a basic version of Generics by using objects. Since all entities in .NET derive from the Object class, anything can be boxed as an object.
Visit
http://www.gotdotnet.com/team/csharp/learn/Future/VCS%20Language%20Changes.aspx[^]
And look under "Building Generic classes today"
"I have a strange ginger man living on my roof!"
"One of the most important things you learn from the internet is that there is no ‘them’ out there. It’s just an awful lot of ‘us’."
-Douglas Adams
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
|
|
|
|
|
Hello!
I want to import DBF file and to bind DataGrid in WinForm.
Is there anybody who knows bind DBF file with DataGrid?
Thanks!!
I'm not who I was
|
|
|
|
|
bania wrote:
import DBF file
Are you referring to a "Data Base File", "DBase" file, or another type of file? If you are referring to some form of database, simply use ADO.NET. Even the wizards in VS.NET (if you have that) will build most of that for you. In the constructor for the form after the call to InitializeComponents, add in the code to fill a dataset and bind it to the gird.
Many examples on CP for that.
Rocky Moore <><
|
|
|
|
|
I have a strange problem... If I launch a standard CommonDialog (OpenFileDialog, SaveFileDialog, ColorDialog), afterwards my buttons' Click events are never fired. It's odd, as I can see that the button is receiving the click (it's visibly pushed down), but the event handlers are never called.
Similar code works in a standalone Windows Forms application, so I think it is something specific about the BandObjects library or the context of a band object. Any possible ideas?
Thanks,
Arun
|
|
|
|
|
To be more accurate, I'm referring to the ToolBar not firing the ButtonClick event.
|
|
|
|
|
Hello,
I got a problem.
I've made a FolderTree by using TreeView control. Now, I want to search one node that represents the user typed directory path in textBox.
I have no idea to do this. How can I search that node.
e.g. user typed : C:\folder1\temp
then the tree control expanded at temp.
Please Help, and could anyone show me some example??
Thank you very much!!
|
|
|
|
|
Here are a little approach ...
<br />
public TreeNode Search(TreeNodeCollection col)<br />
{<br />
IEnumerator myEnumerator = col.GetEnumerator();<br />
TreeNode node = null;<br />
while(myEnumerator.MoveNext())<br />
{<br />
System.Console.Out.WriteLine(((TreeNode)myEnumerator.Current).Text + ": "+ ((TreeNode)myEnumerator.Current).FullPath);<br />
<br />
if ( ((TreeNode)myEnumerator.Current).FullPath == textBox1.Text)
return ((TreeNode)myEnumerator.Current);<br />
else<br />
{<br />
node = Search( ((TreeNode)myEnumerator.Current).Nodes );<br />
}<br />
}<br />
return node;<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
TreeNode node = Search(treeView1.Nodes);<br />
if (node!=null)<br />
{<br />
treeView1.SelectedNode = node;<br />
treeView1.Select();<br />
} <br />
}<br />
I hope that it helps.
Greetings, Jose.
|
|
|
|