|
I think your problem is that the text isn't highlighted when you go back into the textbox, so any characters you start to type are appended to what is already there - hence auto-complete does not work.
The solution is to highlight all of the text as you enter the textbox: Add this line just before you add textbox to the Controls collection
textBox.Enter += new System.EventHandler(this.textBox_GotFocus);
and add this method to the form
private void textBox_GotFocus(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
Unfortunately when you use the mouse to enter the field the caret is positioned wherever the mouse pointer is so the MouseEnter method doesn't work in quite the same way as we'd like.
To get over that you can use the MouseClick event:
textBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.textBox_MouseClick); and add this method
private void textBox_MouseClick(object sender, MouseEventArgs e)
{
((TextBox)sender).SelectAll();
}
|
|
|
|
|
Hello CHill60! Thanks your answer. But my problem is that I cannot input the second word with Autocomplete list item. For example, when I input "May Apr", it should be disapeear "May April" for me to select "April". Now it just can work in frist word "May".
|
|
|
|
|
That's because May April is not part of the autocomplete list - you'll either have to ensure that all combinations are in the autocomplete list, or write a user control to do that - I'll have another look
|
|
|
|
|
I am working on repeater I use the check box control in header and tbody i want when i check the header check box the all check boxes which is in body checked some body help me how is possible.
|
|
|
|
|
You just asked the same question yesterday - got some answers too...If those answers are not good for you than add details and ask for more info, but asking the same question over and over again is not a good way to getting answers...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Hi!
I have defined an event in a certain class:
public class BrokenPackageReceivedEventArgs : EventArgs
{
private readonly byte[] package;
public byte[] Package { get { return package; } }
public BrokenPackageReceivedEventArgs(byte[] _package) { package = _package; }
}
public event EventHandler<BrokenPackageReceivedEventArgs> BrokenPackageReceived;
BrokenPackageReceived(this, new BrokenPackageReceivedEventArgs(dataLst.ToArray()));
It seems that if no method is added to the event, it throws a NullReferenceException. I dont want that exception to occur, in fact I am baffled it actually does occur. Is this really the way events always do if no method is attached? Should I just use a try-catch with an empty catch to get rid of it, or am I missing something?
|
|
|
|
|
I just realized I can do like this:
if(BrokenPackageReceived != null)
BrokenPackageReceived(this, new BrokenPackageReceivedEventArgs(dataLst.ToArray()));
Is this the common way to do it?
|
|
|
|
|
Yes it is. And you could improve it a bit further by making a copy of it before you check it for null:
var copy = BrokenPackageReceived;
if(copy != null)
copy(this, new .....);
..because theoretically some subscriber could unsubscribe during the execution of the null-check.
edit: to clarify, not some subscriber but the last subscriber
|
|
|
|
|
Rather than doing this, try this:
var handler = BrokenPackageReceived;
if (handler != null)
{
handler(this, new BrokenPackageReceivedEventArgs(dataLst.ToArray());
} The reason you will want to do this is that there's a potential race condition because it's possible for BrokenPackageReceived to have a value when you check it, and then be null when you attempt to call it.
|
|
|
|
|
I have set .net Trust level to medium from Full. Its not allowing me to upload file .
can i change web config trust level to full at the same time when i set .net trust level to medium in IIS.
Will it effect IIS settings and fulfill the purpose of medium trust level.
i go through many articles somewhere its written to allow permission and somewhere set to full in web config.
its showing this error when my project is deployed in root folder else working fine .
Please Help.
Thanks
-- modified 11-Feb-15 0:31am.
|
|
|
|
|
Hello everyone,I have given a million records in sql server and asked apply the Jaro - winkler algorithm to find the dupes in those records and I wanted to do it using c#.net. Could anyone help me if you already did such kind of job.I am a fresher so I need some little help in doing it. I would appreciate for your valuable help .
|
|
|
|
|
Help with what exactly?
If you were looking for someone to just hand over their code, you've come to the wrong site.
|
|
|
|
|
|
As a sidenote; it will find "similar" result, not duplicates.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
Is it possible NOT to open the EXE itself and opening instead from within my application only.
What I mean is: I want to launch the WinApplication2 from my WinApplication1 but I don't want the user to go to the windows folder and be able to launch the WinApplication2 direcrly.
Technology News @ www.JassimRahma.com
|
|
|
|
|
Without applying security policies, you cannot prevent the user from being able to launch an application directly. The ability to arbitrarily deny the ability to launch an application would recommend a massive security risk.
|
|
|
|
|
No, you can't prevent someone from launching the other EXE.
Why? Because when a application is launched it's launched AS THE PERSON WHO LAUNCHED IT. This means the process inherits all the security permissions (called a security token) of the account that launched it. Any other process that this process launches also inherits the security token. When your first process launches a second one, it's doing it the exact same way you would. If you try to deny users from launching the second process independently of the first process, your first process won't be able to launch the second process either.
There is a way around this though. In your second process code, check to see if the first process is already running. If not, immediately quit the application.
|
|
|
|
|
Generate two Guids from App1. Start App2 and give on of the guids as a switch. Send the other using TCP/IP, a pipe or a Memory-mapped file.
Shouldn't be too hard to break though (using ILSpy).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
how to select all check boxes in Repeater when I select the Header check box like a g mail trash work
|
|
|
|
|
Either by data binding or event handling. But you need to provide more detail of your problem for a more definitive answer.
|
|
|
|
|
|
Hi guys,
I'm taking C# class, and I got the mark "F" for my assignment.
However, I don't know whether my work was the waste as much as get the zero.
My prof. said me my solution does not satisfy the requirements, but I can't agree with her. I think it was not zero even if I made some mistakes. So, I wanna you guys check my solution whether it was really zero. If you guys also said me I was wrong, I can accept it. but, if otherwise, I'm gonna apply grade appeal.
Here is her direction:
Write a generic method, Search, that implements the linear-search algorithm. Method Search should compare the search key with each element in its array parameter until the search key is found or until the end of the array is reached. If the search key is found, return its location in the array; otherwise, return -1. Write a test app that inputs and searches an int array and a double array.
Here is my code as test code including main():
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GenericSearchLib;
namespace GenericSearch
{
class GenericTest
{
private static GenericStack<int> intStack;
private static GenericStack<double> doubleStack;
private static int[] intArray;
private static double[] doubleArray;
private static int n;
static void Main(string[] args)
{
Console.WriteLine("Enter a number of arraies what you want : ");
string arrN = Console.ReadLine();
n = Convert.ToInt32(arrN);
if (n == 0)
Console.WriteLine("Please enter the number is bigger than 0");
else
intStack = new GenericStack<int>(n);
doubleStack = new GenericStack<double>(n);
intArray = new int[n];
doubleArray = new double[n];
for ( int i = 0; i < intArray.Length; i++ )
{
Console.WriteLine("Enter a integer for int array, one number as 1 : ");
string value = Console.ReadLine();
intArray[i] = Convert.ToInt32(value);
}
TestPush("intStack",intStack,intArray);
Console.WriteLine();
Console.WriteLine("-----------------Complete pusing the array-------------------");
Console.WriteLine();
for (int i = 0; i < doubleArray.Length; i++)
{
Console.WriteLine("Enter a integer for double array, one double number as 2.00 : ");
string value = Console.ReadLine();
doubleArray[i] = Convert.ToDouble(value);
}
TestPush("doubleStack",doubleStack,doubleArray);
Console.WriteLine();
Console.WriteLine("-----------------Complete pusing the array-------------------");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("-----------------Start searcing the array-------------------");
Console.WriteLine();
Console.WriteLine("Enter the name of array what you want to search, int or double : ");
string arrName = Console.ReadLine();
Console.WriteLine("Enter the keyword what you want to search : ");
string keyword = Console.ReadLine();
if(arrName == "int")
TestSearch(keyword, "Int Array", intStack);
else
TestSearch(keyword, "Double Array", doubleStack);
}
private static void TestPush<T>(string name, GenericStack<T> stack, IEnumerable<T> elements)
{
try
{
Console.WriteLine("\nPushing elements onto " + name);
foreach (var element in elements)
{
Console.Write("{0} ", element);
stack.Push(element);
}
}
catch (FullStackException exception)
{
Console.Error.WriteLine();
Console.Error.WriteLine("Message: " + exception.Message);
Console.Error.WriteLine(exception.StackTrace);
}
}
public static T To<T>(this string text)
{
return (T)Convert.ChangeType(text, typeof(T));
}
private static void TestSearch<T>(string searcKey, string name, GenericStack<T> stack)
{
int result=0;
int savePosition=-1;
try
{
for (int i = 0; i < n; i++)
{
result = stack.Search(searcKey, i);
if (result != -1)
savePosition = result;
}
if (savePosition == -1)
{
Console.WriteLine("Searching fail. Your keyword is not matched from array. -1");
}
else
{
Console.WriteLine("Searching success. Keyword : {0} . Index(location) of array : {1}", searcKey, savePosition);
}
}
catch (EmptyStackException exception)
{
Console.Error.WriteLine();
Console.Error.WriteLine("Message: " + exception.Message);
Console.Error.WriteLine(exception.StackTrace);
}
}
private static void TestPop<T>(string name, Stack<T> stack)
{
try
{
Console.WriteLine("\nPopping elements from " + name);
T popValue;
while (true)
{
popValue = stack.Pop();
Console.Write("{0} ", popValue);
}
}
catch (EmptyStackException exception)
{
Console.Error.WriteLine();
Console.Error.WriteLine("Message: " + exception.Message);
Console.Error.WriteLine(exception.StackTrace);
}
}
}
}
This is GenericStack.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GenericSearchLib
{
public class GenericStack<T>
{
private int top;
private int position=0;
private T[] elements;
public GenericStack()
: this( 10 )
{
}
public GenericStack(int stackSize)
{
if (stackSize > 0)
elements = new T[stackSize];
else
throw new ArgumentException("Stack size must be positive.");
top = -1;
position = 0;
}
public void Push(T pushValue)
{
if (top == elements.Length - 1)
throw new FullStackException(String.Format("Stack is full, cannot push {0}", pushValue));
++top;
elements[top] = pushValue;
}
public T Pop()
{
if (top == -1)
throw new EmptyStackException("Stack is empty, cannot pop");
--top;
return elements[top + 1];
}
public int Search(string searckyKey, int position)
{
int reVal=-1;
if (top == -1)
throw new EmptyStackException("Stack is empty, cannot search");
if (searckyKey.Equals(elements[position].ToString()))
{
reVal = position;
}
return reVal;
}
public void Display(string arrName)
{
Console.WriteLine( arrName + " ArrayList : " );
int arrN = elements.Length - 1;
foreach(var value in elements)
{
Console.WriteLine( "Location : {0}, Value : {1}", arrN, value);
--arrN;
}
}
}
}
She pointed out me 2 things.
1. I used stack instead of array.
2. I didn't provide Generic method.
Guys, please let me know, I had to get the zero.
Please show me whether this mark was just her opinion.
If it's unfair, please tell me how I can professionally say it to prof. lol
modified 9-Feb-15 2:18am.
|
|
|
|
|
I'm afraid I have to agree with her: the instructions were pretty explicit as to exactly what she wanted: a Generic search method using an array. You provided a generic method using a stack.
That's not the same. It doesn't meet the requirements: If you were selling cars she asked for a red Ferrari and you supplied a red Ford.
She is right. Possibly harsh, but right. You did not complete the task that she asked you to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks your answer
now, I can understand I provided the solution in a wrong way.
But this different is really big problem as much as get the zero?
I can accept some miss point, but...I don't know..
anyway thank you for your time..
|
|
|
|
|
Would you be happy with a red Ford if you had asked for a Red Ferrari?
Computing is a lot about details: so not reading the assignment correctly could be a significant problem.
As V says: redo it "properly" and ask her if that was what she wanted. It may not improve your grade, but it might be a better solution than annoying the person who will mark your next assignment...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|