|
godspeed123 wrote: to have a pulldown to select the property
Depends. If it's just an enum you can just expose a public property of that type and the PropertyGrid will display a combobox. Otherwise you need a type converter.
godspeed123 wrote: anyone have a tutorial
They hide those in the documentation[^]
|
|
|
|
|
I actually have to read the DAQ Board and retrieve its properties and then want to allow the user to select from it.
So for 1 property I will check the computer for the number of DAQ Boards and allow the user to select the DAQ Board of interest with the serial number. Do I have to use this type converter.
Any example?
|
|
|
|
|
godspeed123 wrote: Any example?
yes, the link in my previous post
|
|
|
|
|
Thanks for the help, I have linked it all up and it works!!
One more question is if I have an array with serial numbers in the Windows Control Library class, how do I send it over to the StringConverter class.
So in:
<br />
public class UserControl1 : System.Windows.Forms.UserControl<br />
{<br />
...<br />
<br />
public string daqSerial = new string[10];<br />
private string testProperty;<br />
<br />
...<br />
<br />
public void RetrieveSerials() {<br />
... <br />
}<br />
<br />
[DescriptionAttribute("Serial"),<br />
CategoryAttribute("Global Settings"),<br />
TypeConverter(typeof(testingPropertyConverter))]<br />
public string TestProp <br />
{<br />
get <br />
{<br />
return testProperty;<br />
}<br />
set <br />
{<br />
testProperty = value;<br />
}<br />
}<br />
}<br />
<br />
public class testingPropertyConverter : StringConverter <br />
{<br />
public override bool GetStandardValuesSupported( ITypeDescriptorContext context ) <br />
{<br />
return true;<br />
}<br />
<br />
public override StandardValuesCollection<br />
GetStandardValues( ITypeDescriptorContext context ) <br />
{<br />
return new StandardValuesCollection(new string[]{"test0", "test1", "test2"});<br />
}<br />
}<br />
So instead of putting those fixed values how do I show the daqSerial Array.
Any help would be greatly appreciated
|
|
|
|
|
Hi,
most of the TypeConverter methods receive a context in argument. You can use the Instance property in this context to retrieve your target instance and request from it some informations like your array.
|
|
|
|
|
Thanks for the response, so how does this work?
The function that I am using has the following prototype
<br />
public override StandardValuesCollection<br />
GetStandardValues( ITypeDescriptorContext context ) <br />
{<br />
<br />
return new StandardValuesCollection( ((UserControl1) context.Instance).daq );<br />
}<br />
This code crashes, so I am clearly doing it wrong.
Whats the correct method. Thanks for all the help
|
|
|
|
|
Your code seems correct (but I don't see it in its whole), so I can't say where your error is...
|
|
|
|
|
the error I get is as follows:
The following exception has occurred:
InvalidCastException: Specified cast is not valid.
Does that help? If not I can put up all the code
|
|
|
|
|
So it means the target instance is not from the type you think it is. In debug mode you could confirm. If you are lost, you could send me a small sample (complete solution, no binaries in the zip file please) to reproduce your issue and I will quickly check. Please use my helpdesk at http://www.visualhint.com/index.php/support/submitrequest/
|
|
|
|
|
Hi,
I retrieved my Outlook Contacts list in a checkedlistbox with only the name and the phone numbers, Now I want to be able to get the phone numbers from the checked contacts from the checkedlistbox to be used somewhere else.
string contName = "";
if (oCt.FullName != null)
{
contName = oCt.FullName;
}
if (chckListBox != null)
{
chckListBox.Items.Add(contName + ", " + PhNum);
}
for(int i=1; i
|
|
|
|
|
I have never worked with the CheckedListBox. Therefore if I needed to solve this problem I would consult the documentation.
|
|
|
|
|
Hello,
I never believe LedMike talking about this "documentaion" stuff.
So I checked it, and have to admit that he is write this time.
There[^] is really a fancy little example which just have to be changed a little to fit your needs.
Have fun reading!
All the best,
Martin
|
|
|
|
|
Thanks
do you know how can set all the items to checked state.
private void btnChckAllOLlist_Click(object sender, EventArgs e)
{
chckListBox.SetItemCheckState = ...
}
I Want to be able to checkall with one button.
Thanks
|
|
|
|
|
Hi,
Trying to convert a string to a hex representation, like so
<br />
string str = "greg";<br />
string hex = "";<br />
foreach(char c in str) {<br />
int tmp = c;<br />
hex += String.Format("{0:X2}", (uint)System.Convert.ToUInt32(tmp.ToString()));<br />
}<br />
which works fine for most characters but when I try feeding in the copyright symbol © (not the html entity © ) I get the hex value A9
Doing the same in PHP I get the value C2A9.
do I need to do something to tell String.Format that the current char is a symbol or something else?
Thanks
Greg
-- modified at 13:26 Tuesday 16th October, 2007
|
|
|
|
|
|
UTF8Encoding ue = new UTF8Encoding();
ASCIIEncoding ae = new ASCIIEncoding();
byte[] bytes = ue.GetBytes("©greg");
foreach (byte b in bytes) {
sb.AppendFormat("{0:X2}", b);
}
bytes = ae.GetBytes("©greg");
sb.Length = 0;
foreach (byte b in bytes) {
sb.AppendFormat("{0:X2}", b);
}
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
The character code for the copyright symbol is 169 (hex A9), so the code works exactly as expected.
What you have done in PHP is not at all the same as what you have done in C#. The byte sequence C2 A9 is not a character code, it's the utf-8 encoding of a string containing the copyright symbol.
To encode a string, use the GetBytes method of the appropriate Encoding instance:
string text = "\xA9";
byte[] data = System.Text.Encoding.UTF8.GetBytes(text);
Now you have an array with the length 2, and the contents { 194, 169 } (hex C2 A9).
---
single minded; short sighted; long gone;
|
|
|
|
|
Trustapple, you really really need to pick up a basic programming book and work your way through it. Granted your questions are getting slightly more complex but seriously - you're still asking similar questions about "functions" that you've been asking for the last day or so!
Trustapple wrote: wen do we create a an object and call the function and wen we can call the function without creating a object.
Put simply, a static method can be called without creating an instance of the object, and an instance method (as is suggested by it's name) must be called on an instance of an object.
|
|
|
|
|
I need a way to get All the records or domains in a NameServer ..
I've red an artice here of C# .NET DNS query component
but it gets all the records for Specific Domain Only ..
Again I need All the Domains or Entrys in this NS
Is that Possible in C#??
Is that Possible using Zone Files??
Is that Possible NsLookUp.exe??
|
|
|
|
|
I'm hesitating to say anything because this can be used for very malicious purposes. What I WILL say is that this is probably not going to be possible on the DNS server you're querying because the server configuration may not let you make such a request. Like I said, ... malicious purposes.
|
|
|
|
|
you're right .. but still there is websites that provide such services
for example "www.domainsdb.net" given the NS it will provide a list of domains contained but the search is limited to 500 results ONLY ..
is it possible to do something like that ??
|
|
|
|
|
Since you don't have direct access to the DNS server, no there isn't. This is because you can give the top level domain as a query and get millions of results. This would bring both the DNS and web server to it's knees processing that many results.
Without direct access to a DNS server that isn't restricted, there's simply nothing you can do unless you get your own DNS server onto the web and can replicate the database of another server.
A query like that is too dangerous to run from an untrusted source. So about the only possible way I can see this happening is if you get your own private copy of a DSN server. Good luck getting that...
|
|
|
|
|
Thanks Dave for ur co-operation ...
but I still have one more question ..
if I have Zone Files actually "I Have it".. can I extract the information i need from it given DNS ??
if yes then how can I Do that ??
Thanks Again ..
|
|
|
|
|
I said this before - I can't tell you. If someone else wants to, that's their responsiblity.
And if you have the zone files for a real world internet DNS server, I don't want to know about it.
|
|
|
|
|
*giggle*
so glad you were 8 minutes faster than me
|
|
|
|