|
I'm a bit puzzled about your intentions here.
So you are trying to convert text to formatted text, however when you execute Clipboard.SetText(rtb.Rtf, TextDataFormat.Rtf); the formatted test *replaces* the original text, hence the next time your code runs it doesn't find any text on the clipboard.
If what you want is having both unformatted and formatted text on the clipboard, there are ways to do that with DataObject IIRC; however even then executing your code twice wouldn't make much sense since it would replace the formatted text by the same formatted text.
Maybe all you need to do is remove the MessageBox?
or think about your functional requirements first and tell us about them.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
My purpose is copy to clipboard selected text (for example in Firefox, Notepad, etc.) using hot key (for example (Ctrl+Shift+C).
I select text and use my hot key. Text is in clipboard, fine. But only if I use it first time. Later my clipboard is empty.
Why?
|
|
|
|
|
Hi. experts...
iam using bulk copy to copy l lac of records from one table to another table which was in a different servers ... when code goes evrey thing fine .... it was getting timeout error .... i checked for 10 thousand rows it was working fine.......... even i incresed the max pool size plz find the solution.........
|
|
|
|
|
venu656 wrote: plz find the solution
er.... No.... THNX
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
venu656 wrote: when code goes evrey thing fine .... it was getting timeout error
Don't know what this means. Is it going ok? Can you post block of your code? Is the timeout on the server it is copying to?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Copy them in smaller blocks of records instead of all at once.
|
|
|
|
|
1 lac means one-hundred-thousand. From the Sanskrit lakshaya : most often transliterated into English as "lakh."
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Below is some code that validates entries in a datagridview against entries in Active Directory and changes the color of the datagridview cells accordingly. A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive and the form doesn't refresh any longer until after the process is finished, thereby causing the progressbar to loose its functionality. How can I overcome this glitch? I would also like to implement a cancel button so that the user can cancel the validation process at any moment, but if a button is pressed I experience the problem mentioned above. Any help would be appreciated. Thanx.
private void btnCheck_Click(object sender, EventArgs e)
{
using (DirectoryEntry de = new DirectoryEntry(adPath, adUsername, adPassword)) //))
{
de.Username = Environment.UserName;
de.AuthenticationType = AuthenticationTypes.Secure;
//these are the attributes that will show
string[] attribs = new string[] { "displayName", "mail", "userAccountControl" };
for (int x = 0; x < dgvManager.Rows.Count - 1; x++)
{
ValidateDetails(4, 5, 6, x, de, attribs); //Second in charge
ValidateDetails(7, 8, 9, x, de, attribs); //Branch Manager
ValidateDetails(10, 11, 12, x, de, attribs); //Regional Manager
ValidateDetails(13, 14, 15, x, de, attribs); //General Manager
ValidateDetails(16, 17, 18, x, de, attribs); //Managing Director
progressBar.Value = Convert.ToInt32(Convert.ToDecimal(x) / dgvManager.Rows.Count * 100);
lblPercent.Text = Convert.ToInt32((Convert.ToDecimal(x) / dgvManager.Rows.Count * 100)).ToString() + "%";
this.Refresh();
}//for
}//using
}
private void ValidateDetails(int cell1, int cell2, int cell3, int row, DirectoryEntry de, string[] attribs)
{
DirectorySearcher ds = null;
string y = "", u = "", z = "", sFilter = "";
//use the username as search key
if (dgvManager.Rows[row].Cells[cell3].Value.ToString() != "")
{
sFilter = String.Format(
"(&(objectCategory=person)(sAMAccountName={0}))",
dgvManager.Rows[row].Cells[cell3].Value.ToString().Split(new char[] { '\\' })[1]
);
ds = new DirectorySearcher(de, sFilter, attribs);
using (SearchResultCollection src = ds.FindAll())
{
SearchResult sr = null;
if (src.Count > 0)
{
sr = src[0];
dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.LightGreen;
dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.LightGreen;
dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.LightGreen;
if (sr.Properties["mail"].Count != 0)
{
z = sr.Properties["mail"][0].ToString();
if (z.ToLower() != dgvManager.Rows[row].Cells[cell2].Value.ToString().ToLower()) //email address
dgvManager.Rows[row].Cells[cell2].Value = z;
}
else
dgvManager.Rows[row].Cells[cell2].Value = "";
if (sr.Properties["displayname"].Count != 0)
{
y = sr.Properties["displayName"][0].ToString();
if (y.ToLower() != dgvManager.Rows[row].Cells[cell1].Value.ToString().ToLower()) //display name
dgvManager.Rows[row].Cells[cell1].Value = y;
}
else
dgvManager.Rows[row].Cells[cell1].Value = "";
if (sr.Properties["userAccountControl"].Count != 0)
{
u = sr.Properties["userAccountControl"][0].ToString();
if (u == "514" | u == "66050") // account disabled
dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Orange;
}
else
dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Orange;
}
else
{
dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Red;
dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.Red;
dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.Red;
}
}
}
else
{
dgvManager.Rows[row].Cells[cell3].Style.BackColor = Color.Red;
dgvManager.Rows[row].Cells[cell2].Style.BackColor = Color.Red;
dgvManager.Rows[row].Cells[cell1].Style.BackColor = Color.Red;
}
}
|
|
|
|
|
Sounds like you need a background worker[^]
Basically, its another thread but fairly easy to work with. The problem you are getting is that your current code is running on the UI thread thus causing issues with user interaction such as button clicks etc.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hardus Lombaard wrote: A progressbar indicates how far the process is from finish. If the user then interacts with the form either by dragging one of the datagridview scrollbars or pressing a button, the program becomes unresponsive
You need to use Background worker in this case, which will help you show the progress of process with out any problem.
Here is an sample application
Using the BackgroundWorker Component in .NET 2 applications
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
how can we convert an image(JPG) in 16 bit image
pls tell me
SHEKHAR
|
|
|
|
|
Hi
Is there any way to replace DirectUIHWND Class of a Window by Usercontrol. Please help
|
|
|
|
|
|
Hello,
i was trying to simplify my code but i have a problem with the code here:
public void Send(byte a, byte b, byte c)
{
byte[] ab = new byte[3];
ab[0] = a;
ab[1] = b;
ab[2] = c;
ab[3] = a ^ b ^ c;
serialPort1.Open();
serialPort1.Write(ab, 0, 3);
serialPort1.Close();
}
When is use this code there is an error in this line:
ab[3] = a ^ b ^ c;
the error is:
Error 1 Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) C:\Users\***\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 27 21 WindowsFormsApplication1
Is there some one that can help me?
|
|
|
|
|
Whenever you use the xor operator (^) (and any of the other operators to) it treats everything as an int .
Change it to
ab[3] = (byte)(a ^ b ^ c);
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)
|
|
|
|
|
Thank you for your fast reply it solved my problem! thank you very much!
|
|
|
|
|
sounds like the resultant value produced is out side byte range and hence overflow that's why its asking for explicit conversion. Make sure the values you passing for a,b and c produce a value within byte range.
|
|
|
|
|
it does, because its sending the result to my serialport, so the value is never bigger then 255.
Thanks for your help!;)
|
|
|
|
|
How exactly would a xor overflow?
|
|
|
|
|
byte[] ab = new byte[3];
ab[0] = a;
ab[1] = b;
ab[2] = c;
ab[3] = (byte)(a ^ b ^ c);
Warning: "index out of bounds" is imminent
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I know that but thank you for the anouncement;) im very happy that you guys helped me out!
|
|
|
|
|
Following on to musefan's point, you have a subtle error in your declaration of the byte array. In this line:
byte[] ab = new byte[3]
You declare ab as a byte array which can only hold three elements. However, in the lines below it, you fill it with four elements; as has been said, this will cause an IndexOutOfRangeException (or something like that) when you assign a value to ab[3]. To fix this problem, change the declaration of ab to
byte[] ab = new byte[4]
This will allow ab to hold four elements, fixing the error
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi,
this is what I would write:
List<byte> list=new List<byte>();
list.Add(a);
list.Add(b);
list.Add(c);
writeWithXor(port, list);
...
public void writeWithXor(SerialPort port, List<byte>list) {
int xor=0;
foreach(byte b in list) xor^=b;
list.Add((byte)xor);
port.Write(list.ToArray());
list.Clear();
}
This way you don't have the hassle of counting bytes and allocating the right array; and you can reuse
writeWithXor() for any amount of data that needs to be followed by a 'checksum'; and of course I would keep the serial port open, probably as long as my app is running.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I want 2 create a component like msn status lable.
that look like a label & a textbox & a dropDownList.
it can drop down show the menu,and it can be edited when I click the label.
how to do that?
|
|
|
|
|
You make a user control with a Label, TextBox and ComboBox
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)
|
|
|
|
|