|
You almost never have to detect overlappings. Windows handles the window stack and z-order automatically. When part of a window is covered, the covered portion won't be updated in the dark. If you force a update, the chances are you also bring that portion to the front at the same time.
Note that this does not stop you from updating the data at any time you want. Windows only controls the rendering on the screen.
Best,
Jun
|
|
|
|
|
What I have done is set a flag while adding a new item. I have also overridden the WndProc to stop it erasing the background and invalidates the new items rectangle. When the flag is set, only the new items rectangle is repainted and not the whole control
However, the effect when a window overlaps my control while this flag is set is that the background is not repainted as my WndProc prevents this. Therefore, I need to somehow detect when a window overlaps my control so that I can tell WndProc to allow the background to be repainted.
I hope this explains my problem. Please feel free to make suggestions on how to do this or a better approach
Thanks again
Peter
|
|
|
|
|
You can optimize the loading of items by calling BeginUpdate() on the ListView, then using the AddRange method on the Items collection, then call EndUpdate(). The Begin/EndUpdate methods prevent the control from redrawing while the items are populated. The AddRange ensures that the control suspends frivilous calculations when adding many items.
|
|
|
|
|
Hi,
Thanks for the reply.
I've already tried BeginUpdate/EndUpdate and AddRange. However, each of these still repaint the whole control causing a flicker.
The setup I have is quite unusual. On a normal winform application both these approaches are successful. However, I have an activeX user control written in C# containing the listview and have exposed methods and events through COM. The activeX control is displayed on a web page using the <object> tags. This has been successful using the BeginUpdate/EndUpdate approach and .NET 1.1 where only a slight flicker was visible. However, now we are updating our desktops to include .NET 2.0 and .NET 1.1. This seems to exagerate the flickering hence why I have take my approach to reduce the flickering.
Thanks again
Peter
|
|
|
|
|
Hi,
Iam using C# Express Edition.I want to create a windows service ,But there is no template for windows service in express Edition.Where can i download the Windows service template.
Thanks in advance.
|
|
|
|
|
|
I pasted up a tweaked version of the service template that I use for my own use. It's hooked up for running it debug (which VS won't let you do with services), just use the NO_SERVICE compile flag. This is similar to something someone posted in an article recently. Anyway, enjoy.
Windows service template (8k)
|
|
|
|
|
Hi all,
I would like to know which one of the above is a preferred tool for c# managed class library's documentation.Please comment on the following criteria.
1. Stability
2. performance(speed,error free document creation etc)
3. Ease of Installation and use(user friedly)
We are using Microsoft .Net SDK V2.0 , without Visual Studio. I would also like to know if it is necessary to have visual studio to use these tools and if not what are the installation procedures. Any comments on this regards would be very helpful.
|
|
|
|
|
sharath nelaturu wrote: We are using Microsoft .Net SDK V2.0 , without Visual Studio. I would also like to know if it is necessary to have visual studio to use these tools and if not what are the installation procedures
How you thought of asking the people who wrote those applications?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
I am sorry, I meant no offence to anybody. I am new to this, I have just started using .NET so i dont know much abt it. I was just trying to get some information thats all. I just wanted to know which one of these tools s preferable for documentation. I am sorry if I didnt phrase the question properly.
Thanks,
Sharath
|
|
|
|
|
Hi,
A good question and I would like to see some people's comments and feedback as well.
Lets see
Glen Harvy
|
|
|
|
|
I have a simple DataTable with one column, "Column1" of type string that is unique.
Consider that following code:
<br />
DataRow row = this.dataTable1.NewRow();<br />
row["Column1"] = "Hello";<br />
this.dataTable1.Rows.Add(row);<br />
<br />
row = this.dataTable1.NewRow();<br />
row["Column1"] = "Hello ";<br />
this.dataTable1.Rows.Add(row);
I will get an exeption saying that column1 is constrained to be unique on the seconde Add(). But as you can see the strings are different. Any way around it?
Thanks!
|
|
|
|
|
Hi,
I'm writing code which will access a mailbox (the actual mailbox is not known at compile time) and read the number of unread messages etc. The mailbox is (as the subject implies) on a Exchange server. I would like to use CDO (haven't really found another way), which supplies a Session object and a Logon method to open the mailbox:
MAPI.Session session = new MAPI.SessionClass( );<br />
Object vEmpty = System.Reflection.Missing.Value;<br />
String strProfileInfo = "server" + "\n" + "username";<br />
session.Logon( "", strPass, false, true, vEmpty, false, strProfileInfo );
However, no matter what parameters I specify, I always get a login dialog. Which I absolutely must get rid of, since this code will run on a web server. I've tried googling alot, but to no avail. Has anybody done anything similar and had some success with it?
Regards,
Daniel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
We maintain a coporate database of user information. Some of the fields need to be synched up with AD user info, specifically LoginName and EmailAddress. I need to write something that will watch or check AD periodically for changes to the user objects, and then populate our corporate database with the new values. My initial thoughts are to write a service that checks the 'ObjectLastChanged' value (if that exists) and pull the fields from that object and update the dB. Have any of you done something similar? Do you recommend another solution? Any comments or suggestions would be appreciated.
Tom Bryan MCAD
|
|
|
|
|
I am using a DataGridView for getting input data from user. In RowLeave event of DataGridView i am checking the cells' values of the DataGridViewRow. There are chances that the user leave some fields empty. I check a certain cell say Column1. If it is empty i want this row should not leave the focus. How could i do that?
Thanks.
|
|
|
|
|
Hi,
try to use the RowValidating event instead. It has a Cancel property which you can set to true when the fields are not set correctly. Haven't used it so far but I think it should be what you need.
Robert
|
|
|
|
|
With your cooperation i solved my problem.
Thank you very much. I expect welcome from you.
|
|
|
|
|
Hi,
I am stuck on this line of code from VB.NET which I am trying to convert it to C#, Dim str As String = Regex.Replace(SomeString, "<br>", Chr(10)).
I'd tried ((char)10).ToString(), @"\n", Environement.NewLine, Convert.ToChar(10) but nothing helps.
The 'SomeString' is suppose to be some HTML text like <a href="/">Home</a> and after runnng the Regex.Replace, it is suppose to be 'Home' on 'str' where all the HTML codes are being scrap off.
Hope you can help me on this.
Jie Liang
|
|
|
|
|
Hello
To convert that to C# will result in.
string str = Regex.Replace(SomeString, "<br>", "\n");
Remember to include
using System.Text.RegularExpressions;
in the top of the file.
Kind Regards,
John Petersen
|
|
|
|
|
Hi John,
Thanks for the speedy reply. It doesn't really work. Let me show you more of the code.
tag = new Regex("<[^>]*>", RegexOptions.IgnoreCase); <--This was suppose to help me get rid all the HTML text which it works in VB.NET and don't seems to work in C#
for (counter = 0; counter <= PageText.Count - 1; counter++)
{
string str = Regex.Replace(PageText[counter].ToString(), " ", "\n");
str = tag.Replace(str, "");
str = Regex.Replace(str, " ", ""); <--By this line, all the HTML text should be alredy gone
str = Regex.Replace(str, "^\\s+", "");
str = Regex.Replace(str, "\\s+$", "");
PageText[counter] = str;
}
So if this Notify me by e-mail if someone answers this message pass into PageText[0] and send to process, it should left only "Notify me by e-mail if someone answers this message".
Hope I didn't confuse you, thanks in advance
Jie Liang
|
|
|
|
|
Use the "Ignore HTML" option when you post code that inlcuded html code.
Now there is a lot of the code missing, so I can't really tell what you are trying to do.
Why don't you use the string.Trim method instead of inventing a new one?
---
b { font-weight: normal; }
|
|
|
|
|
Ok Jie Liang
As guffa said, you should mark the Ignore Html option when posting code here.
I tried to set up a test case which resembles your code. It works for me. I post the code here.
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Text.RegularExpressions;
namespace Tester
{
[TestFixture]
public class Class1
{
public string Process(string[] pageText)
{
Regex tag = new Regex("<[^>]*>", RegexOptions.IgnoreCase); //This was suppose to help me get rid all the HTML text which it works in VB.NET and don't seems to work in C#
int counter;
for (counter = 0; counter <= pageText.Length - 1; counter++)
{
string str = Regex.Replace(pageText[counter].ToString(), "<br>", "\n");
str = tag.Replace(str, "");
str = Regex.Replace(str, " ", ""); // By this line, all the HTML text should be alredy gone
str = Regex.Replace(str, "^\\s+", "");
str = Regex.Replace(str, "\\s+$", "");
pageText[counter] = str;
}
return pageText[0];
}
[Test]
public void TestFunc()
{
string[] PageText = {
"<label for=email_notify>Notify me by e-mail if someone answers this message</label>"
};
Process(PageText);
}
}
}
The output from the Process method is "Notify me by e-mail if someone answers this message"
Kind Regards,
John Petersen
|
|
|
|
|
Hi John, Hi Guffa,
Sorry bout the Ignore HTML thing, I forgot to check it when I modify my post.
Yes, it works, John. After reading your post, I decided to test this small piece of code and as you said, it works. Then I realized I did not show you enough information, sorry about that.
The HTML code that pass into PageText[] should be in full such as '<a href="">Hello</a>' and not 'a href="">Hello</a>', or else it won't digest the HTML.
Now everything's fine, thanks a lot to both of you, you have been very helpful
Jie Liang
|
|
|
|
|
I have two listviews in my app. The user may make multiple selections in one of them, but may not have selections in both at the same time. To enforce this requirement I'm responding to the SelectedIndexChanged event and having it clear the selections in the other LV. The problem is that the clear() method operates incrementally and immediately fires the event in the listview it's working on, which results in both listviews clearing each others selections. I tried using the lock statement, but the second event handler is able to gain the lock even though the first hasn't completed. Since all the examples I've seen are for controlling across threads I'm assuming the problem is that the second event handler is being ran in the same thread as the first.
What happens is the following:
State: LV1 - 2 items selected, LV2 0 items selected
Click on an item in LV2
State: LV1 - 2 items selected, LV2 1 items selected
LV2 handler called. LV1.Clear method called.
LV1.Clear cancels the 1st selection in LV1
State: LV1 - 1 items selected, LV2 1 items selected
LV1 handler called. It calls LV2.Clear called.
LV2.Clear cancels the selection in LV2
State: LV1 - 1 items selected, LV2 0 items selected
second LV2 handler called. Terminates because LV2 has no items selected.
LV1.Clear() called by the first LV2 handler regains control. Remaining LV1 selection is now cleared.
State: LV1 - 0 items selected, LV2 0 items selected
The result I want is: State: LV1 - 0 items selected, LV2 1 items selected
I could use a bool flag as a psuedo-lock to control the updates but am hoping there's a more graceful way to do it.
LV2 has a handler identical to this.
private void LV1SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
lock(this)<br />
{<br />
if (this.LV1.SelectedItems.Count >0)<br />
{<br />
this.LV2.SelectedItems.Clear();<br />
}<br />
}<br />
}
|
|
|
|
|
Sometimes the simple solution is the best. Try removing the event before clearing the listbox and adding it again afterward. Not elegant, but works.
only two letters away from being an asset
|
|
|
|