|
Hi,
I got a solution as well which does same...
toolbarButton_Click(...)<br />
{<br />
this.toolbar1.Focus();<br />
if(!this.toolbar1.Focused())<br />
return;<br />
}
isn't it a smaller and better solution? it simply focuses the toolbar and checks that whether it is focuses or not, if it doesnt get focus then it means that focus is still on the control beign validated. Just try it.
sorry for my bad English.
|
|
|
|
|
When you click on a toolbar button, the control that has the focus doesn't lose it, and thus Validating/Validated events are not generated.
My solution goes to great length to ensure that the focus is given back to the control that has it, so that it acts the same as you.
Your solution simply takes focus away from the currently focused control, and doesn't give it back. I did try something similar before getting to my recursive solution, but I don't remember the details.
I took your code and gave it a try, and this is what I came up with:
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
if(!ValidateFocusedControl())
return;
if(e.Button == toolBarButton1)
MessageBox.Show(this, "Button 1 clicked!");
else if(e.Button == toolBarButton2)
MessageBox.Show(this, "Button 2 clicked!");
} The heart of if is that call to ValidateFocusedControl:
protected bool ValidateFocusedControl()
{
bool result = true;
Control ctl = ActiveControl;
toolBar1.Focus();
if(!toolBar1.Focused)
result = false;
ctl.Focus();
return result;
} I gave it a try and it works as expected, even with controls inside tabpages for example.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
its alitle hard to explane what i wont.. but i will try any way.
lets say i got 2 classes:
public class person
{
private string firstname;
private string lastname;
private ArrayList exames; // (or HashTable) contaning Exame objects
public string FirstName
{
get{return firstname;}
set{firstname = value;}
}
public string LastName
{
get{return lastname;}
set{lastname = value;}
}
public ArrayList Exames
{
get(return exames;}
set{exames = value;}
}
}
public Class Exame
{
private string examename;
private int grade;
public string ExameName
{
get{return examename;}
set(examename = value;}
}
public int Grade
{
get{return grade;}
set{grade = value;}
}
}
so far so good..
but now i want to bind the person object to a datagrid. and i want the datagrid to show the next information:
person mike = new person();
mike.FirstName = "mike";
mike.LastName = "james;
mike.Exames.Add(new Exame());
((Exame)mike.Exames[0]).ExameName = "english";
((Exame)mike.Exames[0]).Grade = 100;
mike.Exames.Add(new Exame());
((Exame)mike.Exames[1]).ExameName = "math";
((Exame)mike.Exames[1]).Grade = 90;
in the next way in the grid:
FirstName LastName english math (thouse are the column names)
"mike" "james" 100 90 (the data itself)
(P.S ignore the problem when a persion doesnt have a serten exame.. and all other small error's i know how to overcome them. i just need to know how to show it like this)
|
|
|
|
|
how display line and column on status bar
what do you method to make it
hello everybody ! good luck to you!
|
|
|
|
|
is there anyway to get all the text in a ListBox as an array of strings (string[]) ?
thanks!
|
|
|
|
|
hi
try with this:
string[] s=new string[this.listBox1.Items.Count];
this.listBox1.Items.CopyTo(s,0);
regards,
pubudu
|
|
|
|
|
|
Is there such a thing as a common code module (like a VB Bas File) where a c# application can declare and populate publicly accesible objects / variables ?
I'm trying to implement Remoting. The proxy class that is used is always declared as New. If I get the class from the singleton running server then I want it to know about the application's state ? Ie is the object on the server connected to the database etc...
Any help gratefully received.
Cheers
Chubby..
|
|
|
|
|
there is nothig like .bas in C#
How ever you can make a class with static members and methods to access them throughout application.
sorry for my bad English.
|
|
|
|
|
|
I have a application on client that will connect to server so i want to get Time on Server from Client. How to do that.
|
|
|
|
|
hi,
If the database in the server ,You can simply run a SQL query and get time on that server computer.
"SELECT getdate() as serverdatetime"
If you run above query after connecting to database in the server,then You will receive the Time on the server.
regards,
pubudu.
|
|
|
|
|
That depends entirely on your server. What are you connecting to? A file share?, TCP port?, a server application that your wrote?, NTP service?, Web Service?, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I'm new with c# and i have a question for you :
it's possible to define a module in c# like in vb.net?
I need to define some utility function accessible by any page of my web application; do i need a class for this? and create an instance of that class everytime i need to call someone of the utility function?
There's some other way?
thanks
|
|
|
|
|
LIUCKAS wrote:
do i need a class for this?
Yes.
LIUCKAS wrote:
and create an instance of that class everytime i need to call someone of the utility function?
Only if you want to. You can create a class with just static methods in it - that means that you don't need to create an instance of the class in order to run the static method.
LIUCKAS wrote:
There's some other way?
There are lots of ways. For example: You could also create a singleton class - that is a class with a private constructor and it manages its on creation so that there will only ever be one instance of the class in existance in the application.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
|
hi friends,please help me. i have written code for into mdi form for openning a child form.
private void menuItem7_Click(object sender, System.EventArgs e)
{
frmBaseForm frmLoad= new frmBaseForm();
frmLoad.MdiParent =this;
frmLoad.Left =0;
frmLoad.Top =0;
frmLoad.Show();
}
when i click menu more then once,this code open more then one form.
i don't want that. it can be solve by using variable and may be enabling disabling the menu item. but i want optimum solution
thnx a lot
|
|
|
|
|
Use this function...if it suits you...
frmBaseForm frmLoad= new frmBaseForm();
ShowMdiChild(frmLaod);
private void ShowMdiChild(Form frm)
{
if(frm==null)
return;
for(int i = 0 ; i < this.MdiChildren.GetLength(0) ; i++ )
if(this.MdiChildren[i].Name.Equals(frm.Name))
return;
//if (! this.Contains(frm))
frm.MdiParent = this;
frm.Show();
}
sorry for my bad English.
|
|
|
|
|
thnx a lot,its working fine
|
|
|
|
|
Hello,
Im' using i'm called matlab using dll ; it's clear how pass a double variables, but i can't pass a string variables, Plz how we can do it ?
|
|
|
|
|
How can i do to write an function which can:
-Trim spaces in the first, last of string and return an space in case of there are too many spaces between letters
-Upper case the first character of string an each letter of string the remain letter is lower case
for example when user input:
aBcd efG hiK
The return string is:
Abcd Efg Hik
Please help me talents.
Thanks and best regards.
I tried so hard and got so far
|
|
|
|
|
Look for the Trim function in the string class, that should help you achieve your first objective.
For the second, you can traverse the string till you hit a non space character, change that character to upper case, then change the next ocurring characters to lower case until you hit a space (or reach the end of the string). You need to use System.Text.StringBuilder for this, as the string class doesn't allow the string to be modified.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi, is it possible to configure HTML formatted message with Log4Net's SMTP appender?
Thanks.
Norman Fung
|
|
|
|
|
I have a sample class as shown below
public class MyAirport
{
delegate void ProcessAirport(string s);
ProcessAirport pa;
public MyAirport(string sAirportName)
{
pa = new ProcessAirport(ProcessMumbai);
}
private void ProcessMumbai(string s)
{
MessageBox.Show(s);
}
public void ProcessAirport()
{
pa("Hello Mumbai");
}
}
in the class above i have used created a delegate instance with statement
pa = new ProcessAirport(ProcessMumbai);
where in i am passing 'ProcessMumbai' directly as a function pointer to ProcessAirport delegate.
now my question is : can i pass function pointer referance by string like,
pa = new ProcessAirport("ProcessMumbai");
if so, please guide.
thanks,
vaibhav
|
|
|
|
|
AFAIK, you can't do that directly with delegates. You need to use reflection for that. Something like
public class MyAirport
{
delegate void ProcessAirportDelegate(MethodInfo methodInfo);
ProcessAirportDelegate pa;
public MyAirport(string airportName)
{
pa = new ProcessAirportDelegate(ProcessAirport);
}
private void ProcessAirport(MethodInfo methodInfo)
{
methodInfo.Invoke(this, new object[] {});
}
public void CallProcessMethod(string methodName)
{
MethodInfo methodInfo = this.GetType().GetMethod(methodName);
pa(methodInfo);
}
}
I created a delegate because your code had one. You can instead call methodInfo.Invoke directly from CallProcessMethod .
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|