|
If you have questions or comments about a specific article, then you should ask in the message board at the bottom of that article - that's what the message boards are there for. This forum is for general C# and related .NET questions.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Does anybody know how to set the color of ListView columns???
I need to set the whole columncolor and not only the background color of a
subitem.
Can somebody help me
Thanks
00ason00
|
|
|
|
|
Unfortunately there's no such thing as ColumnColor in the built-in ListView.
If you want to achive this effect than you's have to set the color of each n'th SubItem (after setting UseItemStyleForSubItems to false for the ListViewItem ).
mav
|
|
|
|
|
Hy everyone!
I do have a problem with my application:
I do want to change the appearence of my application if the user wishes to. I do have a Windows.Forms and two User.Controls which are displayed. The user is able to select items from a combobox which might cause the displayed layout to change.
When I do so then there is some kind of flickering. So I thought of freezing the layout until the changes are done. I did the following
<br />
this.SuspendLayout();<br />
this.ResumeLayout(false);<br />
well but the flickering is still there. The one control is a "single" control but the second one consists of one or more being placed on top of each other with the visibleoption displaying one at a time.
Is the "overlaying" of the controls the reason?
Because I thought as long as I do set the Windows.Forms to SuspendLayout everything in there is freezed until I do call ResumeLayout. But I am not sure if this includes the controls as well, which are added or deleted dynamically. Or do I have to suspend and then resume every element (meaning the controls) as well?
Does anyone of you have an idea, what might be wrong in here?
Thanks!
Stephan.
|
|
|
|
|
Try placing the control in a panel. You can avoid flickering by hiding the panel and showing it when the new controls have been added:
<br />
panelContainer.Hide();<br />
panelContainer.Show();<br />
You can put a "Please Wait..." label under panelContainer , so that the user sees a message until the control are visible again.
|
|
|
|
|
Your question is very vague. What is GetRow() supposed to be doing for you? What are your trying to do? And what do you mean by "another Utility Functions"?
You're going to have to be alot more specific about what your trying to do and the problems your having.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Not really a programming question, but is it possible to have Visual Studio put the project files with BuildAction set to "Content" (for example, an XML or INI configuration files, or HTML pages) to the /bin/Debug /bin/Release folders automatically? I have VS.NET 2003 Pro here, and I'm talking about Windows Application / Console Application projects.
It would be nice to have these files as a part of the project and not need to copy them manually to /bin/Debug everytime I change them, but I just can't figure out how to achieve this. Is there a plug-in for this, or can VS do this automatically?
Thanks for any ideas,
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Yes I have see this too! And reading the docs it would assume it should copy it, but it doesnt...
Best is to setup a post build event and copy the files, tedious, but at least it will work (i wonder is MS will fix that silly little "editor" that doesnt work at all?)
HTH
top secret xacc-ide 0.0.1
|
|
|
|
|
Yes, it helps, thanks for the tip! At least we have something that works.
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Actually, "Content" is for when you build setup projects in VS.NET. If gives you the choice of output, content, source, and (something I can't remember) files from projects you select. This establishes a dependency on the code project for the setup project and automatically copies the files from that category. Nifty, but what you and the original poster were talking about would be nice, too.
I recommend going to http://lab.msdn.microsoft.com/vs2005/[^] and add a request if one doesn't exist already.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi, I am using a ComboBox with a DataView as a DataSource. When I load 0 Value into the ComboBox (which Does not exsist) or set The Selected Index to -1 the ComboBox shows a different Value.
for example after this line:
this.comboBox_currency.SelectedIndex = -1;
sometimes the SelectedValue will be null and other times it will be {2} or any other value.
|
|
|
|
|
You may need to make certain that you are not trapping the SelectedIndex_Changed event or something similar. That will sometimes burn you. One approach I took was this:
...
bool IgnoreChangeEvent = false;
...
if (condition)
{
IgnoreChangeEvent=true;
box.SelectedIndex = -1;
}
...
box.SelectedIndex_Changed(object sender, EventArgs e)
{
if (IgnoreChangeEvent)
{
IgnoreChangeEvent=false;
return;
}
... determine if action is needed
}
This signature left intentionally blank
|
|
|
|
|
I have read some source codes and I've seen that the BeginUpdate method is used before adding items to a TreeView, EndUpdate after adding items. But when I don't use the BeginUpdate and EndUpdate, the items are also added to TreeView.
Can you tell me the differences beetween using and not using these methods. Thank you
Robe
|
|
|
|
|
You can find the answer here[^].
Basically, BeginUpdate prevents the control from repainting until you call EndUpdate. MSDN recommends using this if you are adding items one at a time to the TreeView.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
I need to know how to access images that are stored in the Web Browser Control, and not their urls. I can access the url and load the image for a second time, but I don't want to do that as some of the images I need to access come from a "https" url, and I am getting a Bad Request exception when i try to reload them using the WebClient class. I can definitely right click on the image in the control and select "Save Picture As..." which saves the image to my harddrive, so surely there must be some kind of way to access it from memory.
Any ideas? Thanks
|
|
|
|
|
When you get the image URL by enumerating IHTMLDocument2.images , make sure you are getting the absolute URL including the host information and scheme. If the server's giving you "Bad Request" then use a HttpWebRequest which will give you a little more feedback.
You could invoke the Save As functionality by using IWebBrowser.ExecWB with parameters that are documented in the Platform SDK under "Web Development". Visit http://msdn.microsoft.com/library[^] for details.
Basically, execute something like this:
axWebBrowser1.ExecWB(
71,
0,
path,
null); The first two parameters - enums - should also be defined in Interop.SHDocVw.dll or Microsoft.mshtml.dll; I really don't remember off-hand.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ok, if I use HttpWebRequest to reload the url of the image,when I execute GetRequestStream, it throws an exception that says "cannot send a content-body with this verb type". For the webbrowser.ExecWB, I looked over the documentation and it saves that the first parameter is like clicking on the File menu item, and then selecting Save As... What I would need using this implementation would be to right click on an image in the browser and execute Save As... Any ideas? Thanks
|
|
|
|
|
There's no support for that via IOleCommandTarget (see the docs). You would be able to, however, copy the filename from the save location + "filename_files" directory. Most often, the image retains the filename (only doesn't when a collision occurs).
To simulate a user click would require getting the client X and Y coordinates, translating those to screen coordinates, then simulating a right mouse click. You would then have to guess where "Save Image As..." is located (tends to change positions with versions) and simulate a click. This is all very error-prone.
Why are you using GetRequestStream , though? You do something like this:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
"https://somesecureserver/path/image.gif");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Unless you plan on POST'ing information to the site, you don't need the request stream. You should look at the examples in the .NET Framework SDK documentation. For HttpWebRequest and HttpWebResponse there's quite a unique examples.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ok, after parsing the html code in WebBrowser for the url of the image. I execute
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Right in the call to GetResponse I get the Bad Request Exception that I got using the WebClient class. Is there something else I must assign to my request so that it knows this request is being made from the same app as the WebBrowser? Thanks
|
|
|
|
|
The WebBrowser is an in-process component of your application - it is in the same process. What you're asking for is very ambiguous. You can set the UserAgent to the same as that for the WebBrowser control, but that doesn't necessarily mean it'll work.
You need to be more specific. Is an actual exception being thrown? If so, what is it? If not, is the server returning a page? Have you debugged your code and made sure that your URL is defined correctly while stepping through your code.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I've checked my code, and the url for the image is correct. When I execute GetResponse for the request, a System.Net.WebException is thrown with the message {"The remote server returned an error: (400) Bad Request." } Do you know how I would get the UserAgent of the WebBrowser control?
Thank you,
|
|
|
|
|
You don't - nor can you (at least not in its entirety) - set the WebBrowser's user-agent. You set it on the HttpWebRequest . See the HttpWebBrowser.UserAgent property in the .NET Framework SDK documentation. You could programmatically set this to be the same as the WebBrowser control's with something like this:
IHTMLWindow2 window = (IHTMLWindow2)axWebBrowser;
if (window != null)
{
httpRequest.UserAgent = window.navigator.userAgent;
} That still may not solve the problem. You need to figure out why the server is returning HTTP error code 400. Setting the user-agent may help, but there's many other things that could be wrong.
If you have access to the server, check the lots. If it's ASP.NET, open trace.axd in your browser off the web application's root (like http://localhost/myapp/trace.axd). Tracing has to be turned on for that to work, though, and has to allow connections from your host. All that information is in the .NET Framework SDK under the ASP.NET configuration documentation.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hmm, when I try to do that cast,(IHTMLWindow2)axWebBrowser;,
it throws an invalid cast exception. Is there a different way to cast it?
Thanks
|
|
|
|
|
Then the WebBrowser control doesn't implement the IHTMLWindow2 interface (from a COM perspective - not from .NET*). My mistake.
What you'll have to do then is cast WebBrowser.Document to an IHTMLDocument2 (defined in Microsoft.mshtml.dll) then use IHTMLDocument2.parentWindow and cast that to an IHTMLWindow2 . That will get you the reference you need (don't forget to check for null !) to navigator.userAgent , just like you would in script in DHTML.
* When the ComImportAttribute is present on a type, the CLR does a QueryInterface for an interface on an object instead of a cast as performed in IL instructions.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|