|
Ok, I am designing a custom Control (i.e. ComboBox) in .NET. However, I want to handle a couple Events of the Parent Form so I can handle closing the Drop-Down List appropraitely (I am NOT Inheriting from ComboBox!). I know I can do this somehow by SubClassing, but how do I hook into the Events (I do not want to use a Timer!)?
Can anyone help? Please!?
|
|
|
|
|
It is not really clear here if you are asking about subClassing a control or a form. Each has very different approaches to what you want to do.
So if, for example, you inherited from the textbox control. You inherit all of the base class methods and events. You can (usually) manange your own events by doing:
<br />
private new void Control_Event(parameter, parameter)<br />
{<br />
mycustom event code<br />
}<br />
I say USUALLY because something like modifying the ADD event for a listbox is not possible since that method lives inside the ListItemCollection which is marked as not-inheritable.
Now....if you are actually managing events from ANOTHER control that is on a form that your custom control will live on, that is a different story.
One approach you can take depends on the use, placement, and mangement of the controls be consistant for all users of this form. You create a base form which contains the custom control, the controls you want to capture events for, and any other pretty-pretties such as header data and such.
Code in all of the events you want coded in there such as closing a combo box when the client clicks on a textbox area (as an example). Test out all of your code making sure that the form behaves the way you want it to. Then when the testing is done, change the project type from Windows Application to Class Library and compile it.
Your developers will create reference to that DLL and when they want to create the form, the do an Add Inherited Form... to create a derived class from your form.
THE ONLY CAVIAT that I have found so far is that inherited forms do not create the [STATHREAD] code. This requires the developer to either a) not have this form start a project -or- b) manually add the [STATHREAD] section to the form before compilation.
An inherited form acts exactly like an inherited class --- you can do your own thing but you won't see the base class methods or code. If a developer attempts to override one of the events you had coded, the compiler will stop it letting him/her know that there is a base method already existing. But they can also polymorph it and put in their own code at will.
Hope this is what you were looking for!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Ok, I found the answer to my question. Basically, I added an Event Handler which Hooked intot he Parent Form's LostFocus and GotFocus events.
|
|
|
|
|
Is there way to change the color of the headers in a ListView? Any suggestions, code, links.
Thanks in advance.
|
|
|
|
|
With thanks to Daniel, and others, I have a combo box which lists all my databases, and I am able to get a list of tables with this code:
ComboBox cb = (ComboBox)sender;
m_conn.ChangeDatabase(cb.Items[cb.SelectedIndex].ToString());
SqlDataAdapter dataAdapter = new SqlDataAdapter("select * from INFORMATION_SCHEMA.TABLES", m_conn);
dataAdapter.Fill(m_dsTables);
Now all is good, except that as m_dsTables is bound to my grid, when it updates, it keeps the old values as well as displaying the new. This is not what I want - how can I get the DataGrid to reset itself ? Is it something I've misunderstood about how I am working with the dataSet ? I'm thinking so, but any help would be appreciated, coz I am not sure at this point in time what is going on....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
Is it something I've misunderstood about how I am working with the dataSet ? I'm thinking so, but any help would be appreciated, coz I am not sure at this point in time what is going on....
I think someone asked this earlier and the answer was to un-data-bind it which clears the DataGrid, then you can bind it again and it should then not have the old data-items.
Not sure though, will try it this evening.
[edit]
Just read this 4GysFromRolla.com article and it mentions clearing the database to stop this happening.
[/edit]
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote:
...can you imagine a John Simmons stalker !
|
|
|
|
|
IIRC, Fill doesn't clear out the existing rows in the underlying DataTable.
James
- out of order -
|
|
|
|
|
I'd do a m_dsTables.Clear() before the fill operation.
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Hi,
I would like to create a context menu when a right click on a simple button or any other control. I need this menu with few options to execute other code.
Does any one have any little sample code to do this or maybe some reference?
Thank you in advance,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Hi I search too for this information please Help us.
THX Badgott
|
|
|
|
|
The "Text" property is not showing up for one of my custom controls, although other properties show up. If I make my own "Text" property, the compiler tells me to put the override or new since my parent has the same property. HOw come it does not show up (although many inherited properties show up)? Does it have anything to do with some attribute?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
try this attribute on your custom property.
[Browsable(true)]
|
|
|
|
|
I found about 10 syntax coloring/highlighting articles here on codeproject, but none are for C#. I've been trying to get RichTextBox to do it, but it always ends up being too slow, disrupting the user while the user is typing, if the file is medium sized like 40k. It's not really possible to do with richtextbox in c#, because the interop to do selection is so slow.
Anyone working on such a control or does anyone know of one?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
You can take a peek at how SharpDevelop[^] does it.
James
- out of order -
|
|
|
|
|
i want to creat a dir in system32 dir is it the right path
is there any changes in %systemroot% require for path?
%systemroot%\\system32\\
r00d0034@yahoo.com
|
|
|
|
|
No, that should work. You could also use %windir%\\system32
A good way to check this type of stuff is to type the environment variable in to the Start|Run... box. That will put you right in the specified directory. Or, if you wanted a .NET way to find the System Directory, you could always do System.Environment.GetFolderPath(SpecialFolder.System);
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
i am having string's like following examples in a loop
-------------------
@123456
@65465498
@-65465498
123456k
65465498 k
-65465498 l
how are u
nice dear
--------------------
these are the strings that i want to convert them into integer value but they also contain characters and speces and sentances. how to convert valied strings into int?
can any body tell the good check so that ?
is there any way to neglect character in a string?
r00d0034@yahoo.com
|
|
|
|
|
Well, first off, you would have to remove all the non-numeric characters. Then you could do System.Convert.ToInt32(string); where string is the string that you want to pass in.
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
I'm sure that ToInt32 would throw an InvalidCast exception, you could use a try catch to catch them, or use a regular expression to strip all non-numeric content. PLan A is a hack, plan B would take a tiny bit longer to impliment.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I think I said to remove non-numeric characters...
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
You sure did, but while imran has been here for six months, in that time he does not seem to progress beyond asking the simplest of questions, and not explaining HOW to remove the characters is just begging for another post from him, so may as well answer it all at once.
In fact, he's now asked the same question in the C++ forum. I'm not sure if he was lost when he posted here, or if he's decided to change languages for this project after looking at the RegEx help in MSDN....
It's funny how often you answer a question though, and a day later, someone else posts the exact same answer to the same question.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
dear first of all let me tell you that i am doing my work in dot net that's why i can use any language it might be c# or vc++ (does not matter for myself atleast)?
but some time there are wrong answers for a question thats why it asked again.
as well well as the progress is consern let the day come when i put my project here.
r00d0034@yahoo.com
|
|
|
|
|
imran_rafique wrote:
dear
Why is it that I need to keep telling people who don't speak English that calling me 'dear' is inappropriate ? *sheesh*
I guess you were using .NET, seeing as you asked on the C# forum. Duh. The point is, is how easily you can do some simply string mashing a good reason to choose one language over another ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hey Christian, what's your MSN IM address?
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Sorry, don't have one. I've managed to avoid the IM thing. I ran up Sonork last night when CP when down, but I usually don't run that ( and certainly not here at work ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|