|
Did you try debugging and stepping through the relevent code line by line? Sometimes unexpected exceptions are thrown and handled, or a condition fails. In either case, you should be able to find more information that may help you solve the problem, or provide some additional information to post along with your problem; because, by itself this post doesn't really present any particular problems.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
<br />
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
if ( listView1.SelectedItems.Count > 0 )<br />
{<br />
codeComboBox.Text = listView1.SelectedItems[0].SubItems[0].Text;<br />
modNameTextBox.Text = listView1.SelectedItems[0].SubItems[2].Text;<br />
modAdd1TextBox.Text = listView1.SelectedItems[0].SubItems[3].Text;<br />
modAdd2TextBox.Text = listView1.SelectedItems[0].SubItems[4].Text;<br />
modCityTextBox.Text = listView1.SelectedItems[0].SubItems[5].Text;<br />
modPinTextBox.Text = listView1.SelectedItems[0].SubItems[6].Text;<br />
modPhoneTextBox.Text = listView1.SelectedItems[0].SubItems[7].Text;<br />
modContactPersonTextBox.Text = listView1.SelectedItems[0].SubItems[1].Text;<br />
}<br />
<br />
}<br />
<br />
Thats for the selected index....
<br />
private void codeComboBox_Leave(object sender, System.EventArgs e)<br />
{<br />
ClearSelected();<br />
listView1.Items[index].Selected = true;<br />
}<br />
The index Varaible stores the index of the ID in the listView...
This only seams to execute once ...
|
|
|
|
|
The ComboBox.Leave event is probably not the place you want to be doing this. This event occurs every time your mouse exits the region filled by the ComboBox . Instead, just handle the ComboBox.SelectedIndexChanged .
As far as the problem, if the above suggestion doesn't solve it (indirectly), make sure the ComboBox is throwing the event correctly and step through your code - as I said before - to find where the error is. Also, make sure that your ClearSelected method isn't throwing any exceptions that would cause your code to exit prematurely before the listView1.Items[index].Selected = true is executed.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am creating a web application using dropdownlists in the datagrid.
My question is. I have two dropdownlists in the datagrid. First one select * from sq. That is working Ok.
After the first one is selected the data and pass the argument to Second one
which is retrieved data. Second one does not work. Nothing.
Second query likt select A from sq where name = 'argument'.
Is anyone can help me ?
Thanks
|
|
|
|
|
Unless you're using auto-postback, you'll need to use client-side Javascript to do this. Remember that ASP.NET describes server-side code written in a language that targets the CLR. Only some basic javascript is necessary for some ASP.NET controls to work, but anything in HTML (what ASP.NET generates for most classes) that must change without hitting the server must be performed by client-side script.
So, either set AutoPostBack to true on your first drop-down, or pass all necessary data to both drop-downs and use some javascript and event handlers on the drop-downs (client-side event handlers) to select the appropriate data.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I need to create a combo box control with a custom drop down. Now, before I try to create this from scratch, is there a way to disable the drop down? Thanks for your help
|
|
|
|
|
Disable the dropdown? You mean like a listbox?
|
|
|
|
|
No, I need to disable the drop down box for the combobox control. I need to do this so that I can have a custom drop down appear.
|
|
|
|
|
You could try extending ComboBox , then override WndProc . For the CBN_DROPDOWN notification message (msg id 7), return instead of calling the base.WndProc :
protected override void WndProc(ref Message m)
{
if (m.Msg == 7) return;
base.WndProc(ref m);
} That may stop it, but the documentation for that notification message doesn't mention how to stop it. By not passing the notification message to the ComboBox , though, it shouldn't display the popup window that represents the drop-down. It's worth a shot.
Also, you should consider making your own from scratch. If the above doesn't work, it's often easier making your own controls that trying to change existing ones. Remember that almost every control in System.Windows.Forms is just a wrapper class for their Windows Common Controls equivalent, so the true behavior of the control itself is defined by native code.
If you must make your own, I suggest you download something like .NET Reflector[^] to peer inside how the System.Windows.Forms.ComboBox works for things that aren't apparent in the documentation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi! I'm trying to create a control which is inherited from TextBox and will have OtherControls property where programmer in design-time will pick few controls from the same form.
Question #1: How can i access other controls on the form? Or at least what should i change in my solution (read further)?
I tried to implement UITypeEditor for property OtherControls. UITypeEditor should do next:
1) show a form
2) show a list of controls of MyDerivedTextBox type
3) programmer picks few controls & clicks OK
I managed to achieve goals 1 and 3 , but step 2:
Header of required method in UITypeEditor implementation follows:
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
The problem is, sometime it works, sometime it doesn't. And that's because (LIKE MSDN SAYS) we should not rely on ITypeDescriptorContext because it may return null for its Instance property. That way, i cannot access parent form.
For that reason, next code (in previous mentioned EditValue method) fails with message "Object referrence not set to an instance of an object." (both run-time and design-time):
foreach (object o in ITypeDescriptorContext.Instance.Parent.Container)
Is there any solution?
Thanks!
Sorry for such a long post
Filip Popovic
|
|
|
|
|
First of all, you should be checking for null for each property of your ITypeDescriptorContext before your foreach statement, or put the whole thing in a try-catch to avoid unnecessary errors (though throwing exceptions is far less efficient that performing checks).
Second, you can simplify this by letting the ComponentModel handle this itself. If you specify a design-time visible property that is a Type you are interested in, the designer will automatically provide a drop-down for those types (or at least it's documented that way). This only works for components if I remember correctly, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've already put foreach statement in try/catch block, but that means that if instance property is null i can't examine controls on the form. Imagine yourself using that control, and hopelessly clicking on property expecting UITypeEditor to show up, but nothing happens. And even if instance is not null at that moment and you manage to pick controls, imagine user's face who is using your program when he sees that program is behaving unexpectedly (or does nothing).
I can't use a property that is of MyControl Type, because that way, programmer would be able to pick just one control. And i need that UITypeEditor because programmer should be able to pick an variable number of controls using single property.
Seems like i didn't write original post clearly. Sorry for my bad english.
Thank You, Stewart.
|
|
|
|
|
How often does this actually happen, though, and under what circumstances? I'm sure there probably are instances where it is null , but the documentation doesn't give specifics. The VS.NET designers probably give consistent input while designing. If you're doing this at run-time, you have to make sure that whatever invokes the UITypeEditor provides a proper ITypeDescriptorContext by implementing and using that implementation when invoking the necessary calls.
There just doesn't really seem like any other way to do what you need. The only way to get the instance of your control (or its container, which the ITypeDescriptorContext also has a property for) in UITypeEditor.EditValue is through the ITypeDescriptorContext (or a TypeConverter for that matter). It's the only thing that ties them together.
If your paranoia is getting the best of you (don't worry, it always gets me too), try to evaluate when the Instance or Container properties are null and either avoid those cases or make sure in your implementation that an implementation of that interface is provided (most likely only possible at run-time, since VS.NET and the built-in .NET designers take care of most of the design-time stuff, allowing you to only be a slave to what it provides).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can't tell when does it happen. I forgot to mention that i was working on control about month or two ago. In my case (with my control and FlashTrackBar from MSDN), i was working for a few days, and then for next few the control didn't work (both design-time and run-time). Sometimes it was changing behaviour even during the use of same instance of VS (same day, of course).
I was really mad about this issue. And disappointed when i saw the explanation in MSDN. After few weeks, i've opened the solution and it just worked. The day after, the same error. And so on, hopelessly.
That means that working on a small project might take years, depending on Framework's will!
Unfortunately, i can see no rule to predict whether Instance is null.
However, seems like i'll have to switch to Delphi, because i've already implemented such control in it. Thank you for you help.
Best wishes,
Filip
|
|
|
|
|
Wait, so you you have a problem with either VS.NET's design-time support or some glitch on your machine and it's the framework's fault? Not hardly. I've written a lot of designer support that's used both in design-time and run-time with no problems - ever! And it works on several hundred machines thus far.
You might try reinstalling VS.NET. Besides, if you're talking about Delphi.NET (Delphi targeting the CLR), then you're still using the framework - it doesn't matter which language you use because it all compiles to IL and uses both the BCL assemblies and any other assemblies you reference. There is no difference, except in a few compiler optimizations for the instructions generated here and there.
So, it's pretty evident that VS.NET is at fault here. Uninstall it, clean up your registry and files, and reinstall it. Something's corrupt.
Or switch do Delphi as you said, but just don't go blaming the framework - even though you're obviously having unfortunate problems - for something that's happening on your machine.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Seems like we misunderstood each other. I SAID that JUST controls which use ITypeDescriptorContext.Instance property were behaving badly. NOT ALL CONTROLS. I could still implement designers without problems, but if i wanted to use instance property i would get those messages. Ok?
At that time i was using framework v1.0 and upgraded to v1.1 (if i still remember). Then i had my OS reinstalled (+VS 2003). And i believe that i would still have the same problem, because MSDN still says that there may be some nulls in this interface. Do you suggest me to try again? (now when i reinstalled everything)?
When i blamed Framework, i didn't mean anything bad, it was more like a joke... sounded funny to me at that moment... I'm not a big fan of MS, but i think they did a good job with framework.
No i was not talking about Delphi .NET, because of reason you wrote. I wrote those controls in Delphi 6, so there's no .NET support.
|
|
|
|
|
I am using the app.config for some purposes that it wasn't meant for, or says microsoft, lol. I used a really great example off of code project that allows me to write back to a app.config file while my project is running. My only problem is, it seems that the assembly holds a copy of the file in memory, and when I write back to it, it doesnt reflect the changes when I read from the file again, it shows me the orginial values. Is there a way to refresh the app.config file after writing to it?
Thanks,
Ryan
|
|
|
|
|
What I know about the app.config file, is that it loads with the AppDomain.
Take a look in the AppDomain documentation to see if you can reload the config file.
Free your mind...
|
|
|
|
|
Once a process is executed in an AppDomain , the configuration information cannot be changed. If you must do this, you must have a process that creates a new AppDomain to run your primary application, which must also exit when the .config file changes. Your host (the launcher) would watch for changes to the .config file and respawn your application after it exits. This is how ASP.NET works, where the host is the ASP.NET worker process (aspnet_wp.exe).
You are right to think that the AppDomain keeps it "cached" (it's actually a one-time read per section, and each section is cached when its read for the first time). The only way to re-read the section is to spawn a new process in a different AppDomain that reads that .config file again.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi Everyone...
DOes anyone know how to do a simple HTTP Text Browser? If you do, can you help me out and email it to me no later than Saturday morning to Guiro565@yahoo.com...Thanx
|
|
|
|
|
Slap a multi-line TextBox in a form with an address bar and a couple buttons, then use the HttpWebRequest and HttpWebResponse (or the WebClient ) from the System.Net namespace. Enabling hyper-linking would be a little more difficult, but not impossible.
Why not just add a WebBrowser control to a form? There's plenty of documentation here on CP and the rest of the 'net (just google). Just drop the Microsoft WebBrowser ActiveX control on a form. A couple of interop assemblies are generated and you now have your own container for the WebBrowser control, just like Internet Explorer (i.e., iexplore.exe). It takes care of everything itself. You can handle events, implement interfaces (sometimes need to create an interop assembly for some interfaces, or define them manually), and walk / change the DOM (reference the Microsoft.mshtml.dll assembly).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Would you happen to have any source code on the above. It will be greatly appreciated!
Guiro
|
|
|
|
|
There's plenty of example code here on CodeProject, and much more on the 'net. Just google for it. CodeProject also has a nice search feature you should use.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way without using COM Interop to enumerate the virtual folders in my system from .Net? My requirement is to build a tree view exactly the same as that of Windows Explorer, with desktop as the root.
|
|
|
|
|
Hi, I hope this is helpful to you. I remember reading about this in the WMI SDK. You can get this information using WMI, which does not use COM, so you should try that. However, I cannot give you any help with the code right now, as I am not at my computer.
|
|
|
|
|