|
Hi!
I'm using a PropertyGrid in my Options-Dialog, which shows DropDown-ComboBoxes amongst others. The whole thing should be multilingual (no problem due to codeproject).
The problem with the ComboBox is the following: As return-value i don't want the selected text but a nr (like SelectedItem). The ComboBox is realised the following way:
C#-Code:
public class LogDataSettingsConverter : StringConverter<br />
{<br />
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)<br />
{<br />
return true;<br />
}<br />
<br />
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)<br />
{<br />
String[] values = new string[5];<br />
values[0] = "Delete nothing";<br />
values[1] = "Delete logdata";<br />
values[2] = "Ask user";<br />
values[3] = "Delete alarm flag";<br />
values[4] = "Delete logdata and alarm flag";<br />
<br />
return new StandardValuesCollection(values);<br />
}<br />
}<br />
And the according property:
C#-Code:
[CategoryAttribute("GPS/GSM/ID settings"), BrowsableAttribute(true),<br />
TypeConverter(typeof(LogDataSettingsConverter))]<br />
public String DeleteLogMethod<br />
{<br />
get { return deleteLogMethod; }<br />
set { deleteLogMethod = value; }<br />
}
There's another question according to the PropertyGrid:
Is there a posibility to hide specific properties of the PropertyGrid at runtime (maybe by setting the BrowsableAttribute dynmically at runtime)?
Because the "mighty" of the PropertyGrid i think that this should be possibly, but unfortunately i couldn't find anything corresponding!
thanks, greets
mike
ps.: A little Screenshot from my PropertyGrid:
PropertyGrid
|
|
|
|
|
Hi,
I created a new control in C# and it generated additional code. I'm not sure of the importance of thise code, and can't seem to find anything on the MSDN library. Must I keep it in? Or can I delete it?
If you have any interesting articles on this, please let me know.
The automaticaly generated is:
[DefaultProperty("Text"),
ToolboxData("<{0}:VesuviusNavMenu runat=server></{0}:VesuviusNavMenu>")]
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
I hope someone can help.
Regards,
Brendan
|
|
|
|
|
Hi,
Does C# have similar methods to VB's Right and Left methods/functions?
Lets say I have the following:
string myName = "codeproject";
I need the first (left) 2 and last (right) 2 characters of this string. What I tried was the following, but somehow it feels that there are maybe better ways of doing it:
int start = myName.Length-2;
Response.Write(myName.Substring(5, 2));
Please can someone help.
Regards,
Brendan
|
|
|
|
|
Substring is all you have, I believe.
|
|
|
|
|
This is truly a wierd phenomenon. So I have this service that is going to backup files in realtime that get dumped into folders specified by the user. The user specifies various information for this service to use through a Windows.Forms GUI. That GUI uses a BinaryFormatter to both serialize the data into a file when the user exists the GUI, and deserialize that data when the GUI is opened again to load the data into the GUI. This works fine...no errors and it functions as expected.
So I need my service to deserialize the same information from the file so it can do its thing given the settings the user set up right? Well I use practically the same approach that I used for the GUI, but in the service for some reason there is an explicit cast that causes a InvalidCastException to be thrown at runtime...This SAME cast does not throw an exception in the Forms GUI. Any ideas? Here is two snippets of code from the GUI and the Service. The explicit cast that causes the problem in the Service but not the GUI is the cast from the object "item" to an object of type OffSiteBackupServiceNamespace.Location.
Note: fs is a filestream linked to the data file generated by the GUI
GUI code (no compile time or run time errors):
<br />
Object item = formatter.Deserialize(fs);<br />
...<br />
if(item.GetType().ToString().Equals("OffSiteBackupServiceNamespace.Location"))<br />
{<br />
locations.Add((OffSiteBackupServiceNamespace.Location)item);<br />
addLocationSaveToView();<br />
}<br />
Service code (no compile time errors, throws runtime InvalidCastException):
<br />
Object item = formatter.Deserialize(fs);<br />
...<br />
if(item.GetType().ToString().Equals("OffSiteBackupServiceNamespace.Location"))<br />
{<br />
if(((OffSiteBackupServiceNamespace.Location)item).Checked)<br />
{<br />
saveToLocations.Add((OffSiteBackupServiceNamespace.Location)item);<br />
this.myEventLog.WriteEntry("Active Location read: " + <br />
((OffSiteBackupServiceNamespace.Location)item).ToString());<br />
}<br />
}<br />
thx,
jason
|
|
|
|
|
I'm looking at the tutorial NetworkStuff, and have a question about what is going on in this function:
<br />
private void first_connect(string remote_ip,int remote_port)<br />
{<br />
this.evt_close.Reset();<br />
this.my_connect_remote_ip=remote_ip;<br />
this.my_connect_remote_port=remote_port;<br />
IPEndPoint ipep = new IPEndPoint(System.Net.IPAddress.Any, this.my_local_port);<br />
EndPoint ep = (EndPoint)ipep;<br />
this.datasocket.Bind(ep); <br />
ThreadStart myThreadStart = new ThreadStart(this.my_connect);<br />
Thread myThread =new Thread(myThreadStart);<br />
myThread.Start();<br />
}<br />
Why is this being done before the thread is started for a client connection?
<br />
IPEndPoint ipep = new IPEndPoint(System.Net.IPAddress.Any, this.my_local_port);<br />
EndPoint ep = (EndPoint)ipep;<br />
this.datasocket.Bind(ep); <br />
I thought you did not have to do a bind on a client socket connection?
Thanks for the help.
Tom Wright
tawright915@yahoo.com
-- modified at 16:01 Wednesday 16th November, 2005
|
|
|
|
|
Hi there.
I was wondering about the CheckBox control.
Let´s say one has 10-15 CheckBox controls and wanted to attach a number to each of them (I am not talking about the Text property). For instance cb1 has 250, cb2, has 165, cb3 has 300 and so on. When the checkBoxes are checked could the numbers attached to each checkBox be added together but only the numbers attached to the checkBoxes that are checked?
So if cb2 and cb3 are checked the program would add together 165 and 300.
How would one go about doing this?
Thanks,
FJ
|
|
|
|
|
Hi!
Perhaps the easiest solution would be to assign the value for each CheckBox to the corresponding Tag property.
Then you can simply write:
int sum = 0;
foreach (CheckBox cb in MyCheckBoxCollection)
{
if (cb.Checked)
sum += (int)cb.Tag;
} Regards,
mav
|
|
|
|
|
I read an C++ article at Borland that shows how to hide your C++ application from the process list.
The article: http://bdn.borland.com/article/0,1410,10396,00.html
But is there any way to do this in C#?
Thanks in advance.
//Erik
|
|
|
|
|
yes, you'll have to pinvoke all the api calls. But it appears that this trick only works under win9x, not winnt based OSes.
|
|
|
|
|
That trick only works on Windows 9x. It won't work on NT kernel OS's.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All
Maybe I'm being really dumb, but just can't find a solution to this one- please help!
I'm using c# (on a PocketPC)
I create some XML
I want to send that XML to an ASP page on the web and return an XML result
I'm using XmlTextReader to get XML data from the webpage but I'm lost as to how to send some XML to an ASP page! Is it the same script except that i use XmlTextWriter? Isn't that just for files!?
Thanks in advance
Sal
-- modified at 15:10 Wednesday 16th November, 2005
|
|
|
|
|
How are you making the actual web request? And how does the webpage expect to receive the xml, as POST data?
I would think the most likely thing you want to do is use the HttpWebRequest class to POST the data up to the web page, if you set its 'Method' to 'POST' you can the use the GetRequestStream() method to return a stream to which you can write your xml.
Is that the sort of thing you are after?
Regards,
Rob Philpott.
|
|
|
|
|
That's the solution I was looking for- thank you ---;-@
|
|
|
|
|
I made this wrapper around an unmanaged C++ library and am having some troubles with a messagebox.
Normally when the c++ library encounters an error or whatever, it would return a 0 or whatnot, but on some functions it just decides to show a message box with an error message, totally inconsistency with the rest of the program. This is even worst since I am wrapping the library and then instead of my error message that would come up the user get's this random messagebox popup with some cryptic error message.
Anyways, I was wondering if there is a way to suppress this messagebox from popping up. The messagebox originates from the unmanaged c++ library, so can my C# wrapper class block the messagebox somehow?
/\ |_ E X E GG
|
|
|
|
|
You are not going to be able to block it in C# (well, maybe - but it would be a serious hack)
If you can recompile the C++ library, there is a way to do away with that messagebox. If I remember correctly it is coming from the C libary, so do a search for the messagebox api in the C headers for the #define - then just copy/paste into your header to override, the recompile. I've done that before and it works nicely.
However, on that note, the message you are getting is probably "pure virtual function call" - which indicates that the C++ code needs to be fixed anyway, as there is a bug. Search for "pure virtual function call" on MSDN and there is a full explanation of why you see that messagebox.
|
|
|
|
|
hello all,
i got this message when i try added anther calss to my com+ component
Could not load type DataAccess.Payroll from assembly DataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3033fe621d172f88.
pls can any one know how can i solve this
thank
hoho
|
|
|
|
|
is it thinkable/possible to put you own windwos-form as a mdi-chid in a foreign mdiapplication?
|
|
|
|
|
If you're talking about adding your own MDI Child form to another process MDI Parent, no it's not possible.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, this was my thougt.
thank you for the answer!
|
|
|
|
|
I am writing a program on c#, but I am storing information on mysql and extracting it into c#. I want to have a function on c# where the user can update information. How do I have the user update the information that is stored on mysql.
|
|
|
|
|
You should be able to run a Transact SQL query from your SQLConnection object in you application that does that for you. The SQL command that you're probably looking for is the UPDATE statement which you can find plenty of information about on the web ( Here's one).
|
|
|
|
|
|
I think you are looking for the object Process . Specifically, Process.Start() . You can set it to run sync or async.
|
|
|
|
|
Look in the System.Diagnostic namespace.
|
|
|
|