|
As I said earlier, you cannot set the ShowFocusCues property of the CheckBox from the UserControl since it is a protected property.
The only way to do that is to create your own implentation of CheckBox by inheriting from the CheckBox control (which you have already done).
|
|
|
|
|
hi,
try this one:
1. create your UserControl with the CheckBox inner it.
Code of UserControl:
<br />
dim checkBox1 as new CheckBox<br />
this.Controls.Add(checkBox1)<br />
2. in your main Form where the UserControl is the underlaying control, override the KeyPress event.
Code of MainForm:
sub override MainFormKeyPress(byval ...,....)<br />
for each userControl in this.Controls<br />
if userControl is nextUserControl then 'change if clause that is matches with your conditions <br />
<br />
userControl.KeyPress(byval..,...) 'send the parameter coming from above<br />
set nextUserControl = ... 'get the followed usercontrol of that one line above...<br />
<br />
end if<br />
<br />
next<br />
end sub
3. Send the KeyPress event to the UserControl. (UserControl1.KeyPress or like that, if this function doesn't exists create a public function in your UserControl name KeyPressEvent...)
-> step 4 is not required if you make your own KeyPress function.
4. Override the KeyPress event in the UserControl.
5. In your UserControl handle the KeyPressEvent raised from Main Form... to set the focus to the CheckBox.
sub override UserControlKeyPress(byval ...,....)<br />
for each userControl in this.Controls<br />
if arg.Key is Keys.Return then 'change it clause that is matches with your conditions <br />
<br />
checkBox1.Focus<br />
<br />
end if<br />
<br />
next<br />
end sub
6. !!! This is required to have a correct handling of setting the focus to only one CheckBox !!!
-> In your Main Form KeyPress event you need to decide which UserControl has to receive the KeyPress event, if you don't do this all UserControls receive the Event and the last UserControl that handled the event will focus its checkBox...
7. i hope it works as expected
greetz
|
|
|
|
|
Hi,
I have tried the above code but it is not working. The rectangle indicating focus is not coming.
Madhu
|
|
|
|
|
We use reflection to get properties of a type. Here is a class :
namespace Test
{
internal class MyClass
{
public MyClass(){}
}
class MyTest
{
public static int Main(string[] args)
{
Assembly asm = Assembly.GetExecutingAssembly();
Type[] types = asm.GetTypes();
foreach(Type type in types)
Console.WriteLine(String.Concat(type.Name,":\t",type.IsPublic);
}
}
}
"MyClass" is a "intenal" class. However, there seems no property for decide this in Type Class.
Type.IsPublic, Type.IsNestedAssembly ... all these properties seems not work.
Is there any method to take care of this ?
Thanks.
|
|
|
|
|
You need to check if the type object has NestedAssembly as an attribute. NestedAssembly attribute means that a class is accessible within the assembly.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
"NestedAssembly" means the class is only used in the current assembly.
However, the class is not "Nested" but only "Internal". How to differentiate these two ?
|
|
|
|
|
In that case, just check the IsNotPublic attribute. It should suffice since you cannot define a class as private/protected in a namespace. If that atribute is true, then the class is internal.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hello Everyone,
I am developing a project in VB.Net. I have a form name frmCustomer.vb from which i would be displaying another form named frmAddress.vb when I click a Button present in my frmCustomer.vb. I am being able to display frmAddress.vb form using the SHOW or SHOWDIALOG method but i would like to display the form in such a way that as if looks that the frmAddress.vb form emerges from frmCustomer.vb form. In a nut shell to give some graphics look. How can I do it in VB.Net?
Madhu
|
|
|
|
|
You need to do some experiments with Opacity , Location and Size properties to achieve that effect.
|
|
|
|
|
I think you should set the initial size of the form small. Then, you can handle the Resize event and increase its size in that event till the dimesions you want it to be. I mean if you want the size of form as (100,100), set its initial size as (5,5) and then step that by equal intervals in the resize event till it reaches to (100,100).
Similar thing can be done if you paint the form on your own.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi,
I have tried the way you have said but it is not giving that effect which I want. I want to show my second form in such a way as if it looks that the second form is emerging from 1st form. Some graphics Transition like look.
Madhu
|
|
|
|
|
I just tried this in the Paint event of the form:
if (this.Height < 300)
this.Height++;
if (this.Width< 300)
this.Width++;
If you need that form should grow in all the directions, you will need to position it as well every time you change the height and width.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi,
Thanx for ur help.
This is still working but I am not getting the smooth effect (graphics like effect)of the form emerging. MOreover the controls placed in the form are giving a jerking effect.
Madhu
|
|
|
|
|
Try setting double buffered to true.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
My question was
1) How can I get a large data set from a stored procedure through ADO .NET using a DataAdapter instead of a DataReader?
After several syntactical errors, I found that the I needed to add the parameters to a command, create an adapter from the command, and then a dataset from the adapter.
modified on Thursday, November 26, 2009 7:57 AM
|
|
|
|
|
Recordsets have become DATAREADERS - google for them
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Is there a way to do this without using a DataReader? I need to store a large dataset and do not think the DataReader let's you know the # of Rows returned beforehand. There would be a performance hit for frequent memory allocations to add new rows. Moreover, I may need to copy the data to a new structure to ensure appropriate locality.
My primary concern is performance and reusing data when I have large datasets that I need to access and my database might be far away. At a later step, I hope to write dll's that can operate on the data on the server. I also might use LINQ if I wanted to query a subset of the data.
I was worried that the data reader would return records piecemeal from the server instead of all at once.
modified on Thursday, November 26, 2009 4:05 AM
|
|
|
|
|
You can return either a DATAREADER which gives you one record at a time and remains connected to the database until closed, or a DATASET which is effectively a disconnected copy of the data, which you can cache etc. I misunderstood your OP, I thought you were looking to read the data a record at a time.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks I finally figured out the syntax. I didn't realize that I could pass a command to an adapter's constructor.
|
|
|
|
|
I am looking for a coding buddy who is at a amateurish (ie college) level at any C#, Visual Basic.Net or Visual C++.Net.
This will help improve me and the coding buddies skills and hopefully learn form each other.
Having an instant messaging program such as Windows Live is a bonus!
I am just a college student who wants to learn so if you would like to be a coding buddy let me know
|
|
|
|
|
You should use skype or gbridge
|
|
|
|
|
Hi,
I have a requirement where in we are required to implement an “spell check” for the text we have entered for all Free Form and Text boxes within our ASP.Net application.
User should also get a way to "ignore" when spelling is correct similar to how Microsoft Word functions.
Please let me know if there is any component is available in .Net framework 3.5 or else pointer to the third party tool also be very much helpful.
Regards,
Palak Shah
modified on Thursday, November 26, 2009 7:04 AM
|
|
|
|
|
Google for HunSpell or NetSpell if you want something for free, or AspNetSpell or PolarSpellChecker if you want to buy one
They differ not only in features, but also in (the amount of translated-) dictionaries.
I are Troll
|
|
|
|
|
I was doing some performance testing to compare times for string == string and string.Compare() when I came up with some odd results. What I found was that after 10,000,000 iterations,
string.Compare("aBcDeFgHiJkLmNoPqRsTuVwXyZ", "abcdefghijklmnopqrstuvwxyz", true) == 0;
is almost 17 times faster than
string.Compare("aBcDeFgHiJkLmNoPqRsTuVwXyZ", "aBcDeFgHiJkLmNoPqRsTuVwXyZ", true) == 0;
Wha? I'm ignoring case! How can it take longer to compare identical string values versus ones that differ only in case? I checked out string.Compare() using Reflector though it makes a call out to unmanaged code.
|
|
|
|
|
The common way to do case insensitive compares is to convert both strings to all one case first. As in your first example, one string is already entirely lower case, nothing needs to be done to it. This will probably result in less work.
[Disclaimer: Pretty much just a guess]
[Edit: I repeated your experiment.
I found that method 1 took around 1.7 seconds and method 2 around 1.4 seconds for 10,000,000 iterations. This makes method 2 just 20% (1.2 times) faster. (No where near 17 times).
If you are finding a 17 fold increase (1700%!) I suspect you have some other problem causing an erroneous result. Also, remember that string literals can be handled very differently by the JIT compiler compared to string variables. If you really want to test the methods you should probably be using a list of randomly generated strings to prevent things like literal optimisation or caching effecting your results.
This was my code:
class Program
{
private static int iterations = 10000000;
private static int repeats = 10;
static void Main(string[] args)
{
long method1Total = 0;
long method2Total = 0;
for (int experiementCounter = 0; experiementCounter < repeats; experiementCounter++)
{
Stopwatch s1 = new Stopwatch();
s1.Start();
for (int iterationCounter = 0; iterationCounter < iterations; iterationCounter++)
{
bool result1 = string.Compare("aBcDeFgHiJkLmNoPqRsTuVwXyZ", "abcdefghijklmnopqrstuvwxyz", true) == 0;
}
s1.Stop();
Stopwatch s2 = new Stopwatch();
s2.Start();
for (int iterationCounter = 0; iterationCounter < iterations; iterationCounter++)
{
bool result2 = string.Compare("aBcDeFgHiJkLmNoPqRsTuVwXyZ", "aBcDeFgHiJkLmNoPqRsTuVwXyZ", true) == 0;
}
s2.Stop();
method1Total += s1.ElapsedMilliseconds;
method2Total += s2.ElapsedMilliseconds;
Console.WriteLine("Experiment {0} Method 1: {1} Method 2: {2}", experiementCounter+1, s1.ElapsedMilliseconds,s2.ElapsedMilliseconds);
}
Console.WriteLine();
Console.WriteLine("Averages: Method 1: {0} Method 2: {1}", method1Total / repeats, method2Total / repeats);
Console.ReadLine();
}
}
Simon
|
|
|
|