|
<enum type> type = <enum type>.<default value>;
try
{
typeFromDb = int.Parse(<raw value read from the database>.ToString());
if (Enum.IsDefined(typeof( <enum type> ), typeFromDb))
type = ( <enum type> )typeFromDb;
}
catch {}
|
|
|
|
|
That's very interesting... I'll give that a try.
|
|
|
|
|
just realised i copied the bit of code from net 1.1 project. in net 2.0 you can get away without using try/catch for it is rather expensive and use int.TryParse() method...
the reason behind the whole thing is that you verify that the database values are within your enum , otherwise you may have injected values which just aren't defined...
|
|
|
|
|
Thanks for your input guys. This is how I finally managed to get it working:
object colValue = GetColumnValueAtRow(Source, Rownum);
string colText = Enum.GetName( this.enumType, colValue );
Combo.SelectedItem = Enum.Parse( this.enumType, colText );
|
|
|
|
|
i have a question about making scripting language with C#.
for example, if i have a richTextBox, and i write there:
<br />
a = 1;<br />
while (a < 10)<br />
{<br />
return "abc";<br />
}<br />
(something like that.)
that return me 10 times "abc" on richTextBox.
there is some way to do it?
thanks.
|
|
|
|
|
|
Have a look at my article, it's one of the few that I've come across that deals with .NET 2 if your interested.
Ed
|
|
|
|
|
Hi there.
I have a scenario where I want the user to click on a picturebox, move the mouse and release the click....so that he could select a portion of the image. Now...I want to draw a dotted frame so that the user would know where he has selected.
Can anybody help out on this, even a link/article is helpful.
Thanks.
"I came back from death to make the wrong things right again." - Eric Draven (The Crow)
|
|
|
|
|
|
i've read that the NotifyIcon class in .Net 2.0 can display balloon tooltips. Even after installing .Net 2.0, I haven't been able to do so. When i place a NotifyIcon component on my form and then begin typing the code, the method isn;t listed. How do i go about this?
|
|
|
|
|
Does ShowBalloonTip() not appear in the Intellisense dropdown? See here[^].
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
No it doesnt show me the method. Is this because when I click the Help>>About box in Visual Studio 2003, it shows me .Net framework 1.1? How do I get it to use .Net framework 2.0?
|
|
|
|
|
As far as I'm aware there's no way to get VS2003 to use .NET 2.0 - you'll need to upgrade to VS2005 or you one of the Express editions for an MS solution or one of the other IDE offerings that are out there - eg xacc.
Dave
|
|
|
|
|
Mridang Agarwal wrote: How do I get it to use .Net framework 2.0?
You'll need to upgrade to VS 2005. I think you can install an "Express" variant for free (for 1 yr).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
If you are using VS 2003, then your app will use .NET 1.x. There are several articles here in CP that implement balloon tooltips, some of them very good.
You could try searching[^]
(The articles by Peter Rilling and Joel Matthias look very good)
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Is there a way to use a C DLL to use in a C# Application?
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
|
Does PInvoke work if a create a DLL in any other language too e.g. Delphi?
|
|
|
|
|
Good question, I've never tried before. My guess is, as long as one can export the native methods so that they're visible to C, then yes.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
hi to all,
how can i upload a file from my client(computer) to the server ?
i tried the code below but it gives this error :
"Remote server returned an error (405) : Method not allowed".
WebClient oWebClient = new WebClient();
oWebClient.UploadFile("http://srvdev/philae_edition/TestCompta.txt", "c:\temp\TestCompta.txt");
oWebClient = null;
any ideas ?
best regards and thanks in advance
fady
|
|
|
|
|
In VS 2005 (Winforms Project) you have the following class supplied for you :
class Settings : global::System.Configuration.ApplicationSettingsBase {
This class is actually created by the designer. With the designer you can define your settings (Expand properites folder, and select Settings file). It is nice grid with drop downs that allow you to easily add new settings. The grid columns are basically "Name", "Type", "Scope", "Default Value". Now I haven't had any problems, until I wanted to use a different type that was not in the drop down for the "Type" column.
Documentation says this relating to serialization (supplied by the LocalFileSettingsProvider class):
Serializes the property to disk. It first attempts to call the ConvertToString or ConvertFromString on the type's associated TypeConverter. If this does not succeed, it uses XML serialization instead.
So according to this I would think I could use a setting with the type being set to Hashtable, no? So when I add a setting and set type to Hashtable, I then investigate the xml where it gets persisted, and find a placeholder for the hashtable, with an attribute on the xml node stating "serializeas= xml", but NO values are saved. Doesn't a Hashtable serialize to Xml without any customizations?
I can not find any examples of code where people use Hashtable as a user setting, so any help or reference is greatly appreciated.
R.Bischoff
Tengas un buen dia
|
|
|
|
|
Follow up:
I have gotten it to work when serializing as binary. I placed the following attribute on my setting of type Hashtable:
[global::System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
I guess Hashtables can serialize out of the box in binary mode, but not xml.
R.Bischoff
Tengas un buen dia
-- modified at 11:28 Thursday 23rd March, 2006
|
|
|
|
|
Hello,
I just wondering what is the best way to relay certain information back to the parent window, from invoked dialog window?
I have MainWindow, that launches dialog:
Options optionsWindow = new Options(user);<br />
optionsWindow.ShowDialog(this);
In the options dialog the user can set to display toolbar, etc..
When the user clicks the Ok button to close options dialog, I want to update the toolbar status in the mainwindow. What would be the best way to do it.
For now I use:
>((MainWindow)Owner).UpdateToolBarStatus(currentUser.ToolBarVisible);<br />
|
|
|
|
|
There are several ways that actions in one window can notify the parent of what is happening. For example:
In your optionsWindow, you can have it raise events back to the parent that are specifically created by you. (example: UpdateOptionsEvent using an OptionsEventHandler in the MainWindow)
Another way is that you have the MainWindow register as a subscriber to the options :
Options optionsWindow = new Options(user);
optionsWindow.ShowToolBarStatusChecked+=this.StutusCheckEventHandler;
It all depends on if you want the parent to respond to specific, single events (checking a box) or continuous events (the options cause a process to run in the child that you reflect the status of in the MainWindow).
Hope this helps.
|
|
|
|
|