|
You know this is really weird!
if you use:
this.listBox1.DisplayMember = "BackColor";
instead of "Name", it displays the BackColor, no problem.
I realise that this doesn't solve your problem, but it is very interesting.
I'm going to play with this for a while, but if you find a solution in the mean-time please post it here.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Weirder, and weirder.
If you try doing the DataBinding in the designer, select the FormsCollection as the DataSource . When you try to select the DisplayMember , all of the public properties of Form are there, except for Name .
Maybe the only way to do it is, as Luc suggested, put the Name into the Tag property if you aren't using it, and use that as the DisplayMember .
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Googled a bit, found some similar complaints, no solutions.
Also found this article dated 27 Sep 2004 Best Practice for Binding WinForms ListControls[^] which seems not to have had problems with DisplayMember="Name" on ListBox controls !?!?!?
It does feel like a .NET bug that maybe did not exist at first.
|
|
|
|
|
OK, this one is really, really, wacked. I've never come acrossed a problem like this before, but then again, I try to avoid using just "Name" as a property of anything. I usually use a more descriptive identifier, like "FormName", but that's just me.
I don't know what his "FormsCollection" class looks like, but I got around the problem by using the above technique in a custom collection that holds an instance of each form and it's name as a seperate property, called, what else, FormName.
His code in his original post looked like it was just scanning the assembly for Form classes and creating an instance of each one, adding it to a collection for later use. That looks like a Dictionary to me.
|
|
|
|
|
Hi Dave,
I agree the OP could have done things differently and never encounter the problem; OTOH the binding behavior is strange.
IMO the Name property should behave like any other property, however I did notice one peculiarity using Reflector, not sure it is relevant though: the getter, when no name is present, returns Site.Name instead.
I have no idea what all the Site stuff is about, could this be the cause of it all?
|
|
|
|
|
Luc Pattyn wrote: the getter, when no name is present, returns Site.Name instead.
Which class/property did you find this in??
Luc Pattyn wrote: I have no idea what all the Site stuff is about, could this be the cause of it all?
Don't know, but it sounds like it might be. The problem I have is that "if no name is present", then why does it appear like that should read "if no name is present, or name is 'Name'"...??
Damn! I wish I could step into the .NET Framework source to see where it goes with this. I can't use it where I work.
modified on Friday, April 17, 2009 11:07 AM
|
|
|
|
|
This is what .NET Relector 5.1.5.0 shows for System.Windows.Forms.Control.Name:
public string get_Name()
{
string name = (string) this.Properties.GetObject(PropName);
if (string.IsNullOrEmpty(name))
{
if (this.Site != null)
{
name = this.Site.Name;
}
if (name == null)
{
name = "";
}
}
return name;
}
|
|
|
|
|
No wonder I couldnt' find it. I never looked at the Control.Name property! Duh!
But, his forms must have a Name, right?? So this getter should never get to the IsNullOrEmpty = true code. It should always return the correct name. ....Unless GetObject() is returning something it shouldn't be.
Damn, to be able to step through this code would be great...
I was looking at the BindingContext, BindingBase, DisplayMember, and everything else along those lines. I can see where BindingBase goes through properties of an object, but there's nothing that would cause it to ignore the "Name" property.
|
|
|
|
|
Hi everyone..
I have a problem creating a AxMsComm list. This is my code:
<br />
public static List<axmscommlib.axmscomm> lstModem = new List<axmscommlib.axmscomm>();<br />
lstModem.Add(new AxMSCommLib.AxMSComm);<br />
lstModem[0].Enable = True;<br />
lstModem[0].Tag = -1;<br />
lstModem[0].CommPort = 1; <br />
.<br />
.<br />
While I am running my aplication I get the following exception:
<br />
InvalidActiveXStateException<br />
I searched for this in google and I found that this is because .NET doesn't allow to create new COM objects dinamically.
Is this true? Does anyone know a workaround of this?
Any help would be apreciated! Excuse my English if I made a mistake.
Ivan.
|
|
|
|
|
If it is a serial port you need, why don't you use the SerialPort class?
|
|
|
|
|
I was wondering that too !
Its not my fault! This aplication is implemented in this way
|
|
|
|
|
Is it possible to run an embedded WSF script?
I know I can run the script if it is external to the program with the System.Diagnostics.Process class but I would like to make this a standalone exe so it is portable.
any code examples would be great or the class I should research more.
thanks
|
|
|
|
|
Hello
I am trying to display the names of all the .rpt files in the reports directory in a gridview. I also need the file name to act as a link to open the .rpt file. So far the code below returns all of the file information in the gridview but I need to filter out just the file name and turn it into a link.
DirectoryInfo di = new DirectoryInfo("C:/Inetpub/wwwroot/Reports");
FileInfo[] rgFiles = di.GetFiles("*.rpt");
gvReportList.DataSource = rgFiles;
gvReportList.DataBind();
foreach (FileInfo fi in rgFiles)
Any help would be greatly appreciated.
John
|
|
|
|
|
like this
void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(File.Exists(listBox1.SelectedItem.ToString()))
System.Diagnostics.Process.Start(listBox1.SelectedItem.ToString());
}
void getDirectories()
{
DirectoryInfo di = new DirectoryInfo("C:\\");
foreach (FileInfo f in di.GetFiles("*.txt"))
{
listBox1.Items.Add("C:\\" + f.ToString());
}
}
Oops that's with a listbox. Well it shouldn't be too hard to do that with a gridview anyway.
|
|
|
|
|
Thanks for the quick reply. Your correct that it should'nt be too hard to do with a grid view but I am so new to this that for me it is hard. Any more explanation would be greatly appreciated.
|
|
|
|
|
Yeah sorry I didn't but alot of effort into explaining that
getDirectories is called at the beginning of your app
DirectoryInfo di = new DirectoryInfo("C:\\");
^^You have this done already
foreach (FileInfo f in di.GetFiles("*.txt"))
{
listBox1.Items.Add("C:\\" + f.ToString());
}
^^This gets all the files you want in the directory and adds them one by one to the listbox with the address of the files you have found
void listBox1_SelectedIndexChanged(object sender, EventArgs e)
^^This is the event handling method which occurs when you click on one of the items in the listbox
if(File.Exists(listBox1.SelectedItem.ToString()))
^^This makes sure that the file actually does exist before opening it- so it won't cause an exception
System.Diagnostics.Process.Start(listBox1.SelectedItem.ToString());
^^This opens the file(from the name of the listbox item you have clicked) with whatever program is the default for it's file type. i.e *.txt with notepad...
|
|
|
|
|
Hi All....
How can i use MAX() function in XPath.
1) By Googling... showing comparing node values.. some thing like
/root/node[not(@val <= preceding-sibling::node/@val) and not(@val <=following-sibling::node/@val)]
2) But I want to work like this
xd.SelectNodes("max(//dgn/one/@id)");
from the reference
http://www.w3schools.com/xpath/xpath_functions.asp#anyuri
Any Idea...?
Thx for the time.
Enjoy!!
Siddharth
|
|
|
|
|
I've got a C# Windows app with an Adobe PDF Reader Control in one of the forms. I'm using acrobat to place buttons in the PDF that will be viewed. I need some way to make the button click in the PDF to be registered as an event in my C# app. I'm having a hard time figuring out how to do this. Would this be easier with an Adobe Acrobat control instead of Reader??? I understand that it might be necessary to put some Javascript in the PDF that runs when the button is clicked and then reference it through my C# (a document level function???). If anyone can guide me in the right direction, it would help immensely.
Any help would be greatly appreciated and please keep in mind that I'm pretty new to C# and know nothing at all about JavaScript.
Thanks,
Engineer Joe
|
|
|
|
|
Where did you get the adobe pdf reader control?
If you create an click event handler for the control it should register when you click it.
Wait now.... that was stupid!
modified on Thursday, April 16, 2009 12:26 PM
|
|
|
|
|
got the control by adding reference under Project ---> Add Reference. Chose something like AcroPDFLib from the COM tab. Then right-clicked the toolbox, choose items, and chose Adobe Reader. In my code, I open the appropriate PDF. So I get the PDF to open with no problem. Now I have to get it to register a button click in the PDF. Problem is that it has to be done at runtime, and i'm also not sure adobe provides a way to reference the event through C#. I'm not that great with event handlers...til now i've just chosen them from the menu options...but that's not possible with a button that isn't present until runtime... I've seen some some code that supposedly runs a javascript function in a PDF when a button is clicked, and i hoping that I could create an event like that somehow.
Sidenote: I'm amazed at how very little functionality the Adobe Reader control has. I haven't found a way to actually get the X, Y, and Zoom coordinates of the viewing window... They can be set easily enough, but I haven't found a way to GET them.
|
|
|
|
|
Take a look at this[^] then check if the click is inside the pdf control.
Hope this helps
|
|
|
|
|
While this can tell me everything about the mouseclick, i can't find how it will tell me anything about a button being pressed... There's no way for a mouseevent itself to convey what button was pressed. It seems that the original problem of not being able to identify a button in a PDF is the problem... Maybe I should repost the question in that manner...My subject title is misleading now that i know more about the subject. Thank you for the reference to this tool though. I can see it being useful for me in the future.
jpc
|
|
|
|
|
Hi
How to convert System.Type to Form ?
i wrote this code :
FormsCollection forms = new FormsCollection();
foreach(Type t in types)
{
if (t.BaseType == typeof(Form))
{
Form frm = (Form)t;
forms.Add(frm);
}
}
but, the following error message display :
Cannot convert type 'System.Type' to 'System.Windows.Forms.Form'
How to solve this problem ?
Thanks
|
|
|
|
|
I don't understand what it is you are trying to do (what is types?) but you could consider if (t is Form) forms.Add(t as Form);
|
|
|
|
|
You will need to instanciate a new Form in your if block, a Type is a Type, not an object so it can't be cast.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|