|
Hello!
I have a very specific question and that is about how to inherit a visual
control for example the control System.Windows.Forms.TextBox without causing
the environment to delete the control when there are some compile errors.
It's the same problem with any visual control that you inherit. The control
is deleted as soon as you use the View Designer when there is compile error.
It's very easy to reproduce my problem. You can do it in this way.
1. Create a class called ExtTextBox like this. In my example here I have
removed the namespace. But if you include namespace make sure you have
access to it.
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}
As you can see this class ExtTextBox inherit from the ordinary components
System.Windows.Forms.TextBox in the .NET framework
2. Create a windows form with any name. The default is Form1
3. Use the View Designer and drag the control TextBox into the window form.
My control was called textBox1
4. Because I want the control textBox1 to be an instance of ExtTextBox I
have to edit the InitializeComponent() I don't have any other idea.
Here is an extract from my windows form called Form1.
Only the interesting rows is written. Two rows is important here.
First saying that control textBox1 is of type ExtTextBox.
Second edit the InitializeComponent and say that textBox1 is an instance of
ExtTextBox.
public class Form1 : Form
{
private ExtTextBox textBox1;
...
...
...
Private void InitializeComponent()
{
this.textBox1= new ExtTextBox();
...
...
...
}
}
5 Compile. Hopefully you don't get any compile errors. When you run the
application only the textBox is being displayed. The problem might start
even here. If you get any compile error and you use the View Designer the
control named textBox1 is being deleted.
6 If you don't get any compile error make a change so you get a compile
error and then use the View Designer the control named textBox1 is being
deleted.
7 Now to my question. I can't use controls that being deleted automatically
when I get compile error as soon as I use the View Designer.
8. If I want to use inheritance on visual control how do I do. I just can't
have it as it is now.
9 I just can't use inheritance in the way I do now.
10. I hope that you have a good suggestion how I should use inheritance on
visual control to avoid this kind of problems.
Additional information: I have a project containing
several forms and some code class files. One file in the project is a code
class file which contains this ExtTextBox in this way.
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}
When you build the project(assemby) and you get some compile error and you
then use the View Designer on a form containing this inherited control the
control will be deleted.
I have also noted that you can avoid that the control is being deleted but
it's a very annoying way to do it on.
Before you build the project(assembly) you click on Windows->Close All
documents.
Then you build and you get some compile error and you can still use the View
Designer and see the control.
I just can't use that solution having to close all the documents every time
before I build the project.
When I use inheritance I want to extend for example the TextBox class by
additional functionality.
If I create a userControl(see below) for example like this. I can't extent
the class TextBox with additional functionality because the control is a
member in the UserControl class. I can extend the functionality of class
UserControl1 but that is not what I want.
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.TextBox textBox1;
...
...
...
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox():
...
...
...
}
}
So the main question is how do I do if I want to inherit(extend) a visual control class for example TextBox without having the TextBox control to be deleted as soon as I use View Designer.
Is it possible that my problem is a kind of bug in the .NET framework.
I use VS 2003.
//Tony
|
|
|
|
|
How can i remove a datarow from a dataset after validating some new added records without traversing the whole datarow collection. If i get the dataset by using GetChanges(DataRowState.Added) method it returns a new dataset hence if we enumerate on it. It doed not allow to delete in actual dataset.
<pre>
DataSet dstAdded=dst.GetChanges(DataRowState.Added)
foreach(DataRow dr in dstAdded.Tables[0].Rows)
// Some validation ...
dstAdded.Remove(dr) // Removes from Added Dataset
dst.Remove(dr) // Gives an error DataRow does not belong to dataset
</pre>
|
|
|
|
|
I am developing a client server application. For to do that I opend the port 1234 in two machines and send some data to destination.
UdpClient udpClient = new UdpClient();
udpClient.Connect(123.123.123.123,1234);
Byte[] sendBytes = Encoding.ASCII.GetBytes("TEST");
udpClient.Send(sendBytes,sendBytes.Length);
But I am working in a LAN. Means my IP address is local to this LAN. I want to communicate to the machine in a different network. How can I get the actual IP address ?. Eg : my ip address is 192.168.1.16 ( if give the command ipconfig in command window). Its local to my network. But my IP in the global status is our router IP. The how can I identify each computer from another network ?. How yahoo messanger in identifying each computer in the lan ?
any help Please ...
Thanks in advance
Cheers
Jijo
|
|
|
|
|
To get your externnal IP adress you can go to one of the many sites that provide this information.
If you want to know how the router keeps track of the traffic, read up on NAT[^].
---
b { font-weight: normal; }
|
|
|
|
|
|
I am working at a project about using IE printing components. So the IHTMLDocument2 interface was adopted by me. But i need to user IPersistStreamInit interface of IHTMLDocument2. Because the IPersistStreamInit is in System.Windows.Forms.UnsafeNativeMethods, which is declared as internal, I can't declare any variables with data type of IPersistStreamInit. Recently I have learned about the reflector, but this seems not feasible. Who can tell me how to do this? Thanks very much.
|
|
|
|
|
Hai Folks.......
I am using Nullable.Wrap() function with beta version .Now i am upgrade to new release .I dont why they removed this function from Nullable class .OK anybody know how can i change my current code to work properly ..
With Regards & Thanks,
Kiran Kumar Singani
|
|
|
|
|
When i use Keypress to catch Keys in TextBox. When it run, i want to copy A text from word, notepad....But i can not use Right click/paste on it. I have Catch "Ctrl+V" it is ok.
Now i want to Fix it.
Please help me!
superdragon
|
|
|
|
|
i'm sorry, i have some misktakes with textbox Event changevalue. That is reason i did not do what i want.
superdragon
|
|
|
|
|
why my search function in cystal report cannot work when i type a string, the result always display "end of search"
angela
|
|
|
|
|
Who can help me this problem with C# program?
dny
|
|
|
|
|
I've worked with a couple barcode readers from Symbol a few years back. Once the data was scanned the "wand" or reader in our terms was put into the well (i.e. the RS-232 conversion port). So in my case as soon as the wand touched the port it started blasting ASCII data. The data was delimited by START and END bytes and it was a halfway tricky exercise to make it bulletproof. Reading RS-232 was similar to writing an Interrupt Service Routine except you have to deal with behavior of the UART (Universal Async Recv Transmit). I suspect you are still up against that to some extent but these days I have heard the vendors have SDKs. Also, you can probably find a solution you can adapt by googling the net.
Good Luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
So C# has a HashTable in the form of Dictionary<K,T> – That’s great std did not have this, and it was lacking for its absence.
C++ C#
List<T> LinkedLink<T>
Slist<T> Queue<T> (if that’s all you used slist<T> for then okay) // I can’t remember the c++ single linked list name.
Slist<T> Stack<T> (Ok, so maybe there’s more code generated in c++ than needed)
Vector<T> List<T> (misleading name for me, and I can not see doco on the behaviour of deleting/inserting in the middle, realloc? Memmove?)
Now the gaps:
?? Dictionary<K,T> (Great! We have a HashTable this is cool)
?? SortedDictionary<K,T> (Curious – more comments below)
Map<K,T> ?? (Umm? Does this gap imply that we shouldn’t need a tree container?) (map<K,T> and set<T> are red-black trees)
Set<T> ?? (Again, what does this absence mean? A Dictionary<K,T> will do in this case, but there is extra unnecessary code there).
In practice we may find that we can use the SortedDictionary<K,T> where we used to use map<K,T>, but what is the cost/benefit of each?
I don’t know, I don’t know how to find out apart from testing it!
So, I’m asking you! Please what is going on in these containers?
Especially List<T> and the realloc/memmove issue.
Jules.
(Excuse my poor formatting, its been a while between posts)
|
|
|
|
|
I am a C++ guy also! I cannot answer your question. You probably already know that these generic containers are managed on the GC heap. Thus, any realloc/memmove issues are probably managed memory issues. The generic containers are faster and more efficient than the object-based ones but you pay for the managed memory features.
|
|
|
|
|
definetly sounds plausable - However, as you suggest it implies that the 'array' inside List<t> is not actually a continuous block of memory.
If this is the case then I assume (of course) that there is at least one extra level of redirection to get to the data from the array indexing. I doubt is does what vector does, which it only grow and only shrink when the appropriate method is called (I forget what its called resize() or something).
|
|
|
|
|
hi
new to using c# and datagrids and having a few issues. i have a couple of issues that would help me along.
i create a connection to my data, a dataadapter and then a dataset. i fill the dataset and then link my datagrid to it - this all works fine.
1. if the user double clicks on a cell/row, i want to open another form, passing info about what has been clicked. i can see how to pass the location of the click, but not the actual data itself. do i get this from the datagrid, or somehow from the dataset?
2. single/double-clicking on the grid should highlight the entire row, and not just the cell - is there a way of doing this?
many thanks!
barry
-- modified at 17:57 Wednesday 15th March, 2006
ps. also need an absolute reference to using datagrids - if it exists!
|
|
|
|
|
1. Have a look at the HitTest function. It takes a pixel coodinate and tells you which cell is positioned there. With this info you can use the indexer of the grid:
private void dataGrid1_Click(object sender, System.EventArgs e)
{
Point screenPos = Cursor.Position;
Point gridPos = dataGrid1.PointToClient(screenPos);
DataGrid.HitTestInfo hti = dataGrid1.HitTest(gridPos);
if (hti.Type == DataGrid.HitTestType.Cell)
Console.WriteLine("Contents: " + dataGrid1[hti.Row, hti.Column]);
}
You could also use the MouseDown event. In this case you would get the relative grid pixel coordinates right in the event arguments.
2. Have a look at the Select and Unselect functions from the datagrid.
|
|
|
|
|
Is there a way to capture mouse input on a form made transparent via the TransparencyKey?
The same problem, a different type of solution:
I have a custom user control designed that has a transparent background using the following technique:
protected override void OnPaintBackground(PaintEventArgs e)
{ //base.OnPaintBackground(e);
}
//add transparent property
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
This effectively stops the program from drawing the background of the control, so the painted object is drawn on a transparent background. However, when repaint the object in a different position on the control, the old image remains (because the background was not redrawn to erase the old image). The image changes with every mouse move, so I need an effecient way to erase the old image while preserving transparency.
A lot of methods to erase the old image, ie, erase the control and start with a clean slate, destroy the transparent effect.
Any thoughts anywhere?
|
|
|
|
|
Just a bump to make sure this post isn't lost forever.
|
|
|
|
|
Microsoft tries to helping object developers to close the gap between the relational world and the object world.And they call this "object modelling approach" linQ.
Using "custom business entities" in enterprise programming with linQ might seem the best thing after "sliced bread" but it isn't.
For my part I have written my Mappers and used commercial OR/M tools.
They mostly provide the same thing.
__Read the table from the database.
___Put that into a some HELPER thing.(DAO,DAL,ORM)
____Put that into your custom business object
_____Read from your business object.(if u can )
I see NO REASON for this "Unnecessary Pull and Push".
Can anybody explain me why we shouldn't use a typed dataset and go to OR/M?
I hear people saying Typed dataset is really concrete and not flexible to requirement changes.
U even might lose staff when u have to regenerate it.It is far away from perfect.But with typed dataset...
1.U can easily see design time errors + intellisense
2.They also provide rich data for paging,sorting and all kinds of UI staff.
3.For requirement changes,for performance and also for JOINS u should use VIEW's in database modelling.U can also use VIEW's with typed datasets in ADO.net 2.0.really nice graphical component.
On the other hand "object modelling approach" makes NO sense.As to access a group of data,u have to create a custom collection where it is the WORST thing u can do in the business software development in terms of performance.(Arrays are evil).Such as 12 million ORDERS,can have 55 million ORDER_DETAILS and 5 million CUSTOMERS and no LAZYLOADING can help u.Object models use RAM and CPU resources which are really important in terms of performance.if u have more complicated object graph it will be slower.Some might say lets take the performance parameter out and think without it,those people see a "butterfly effect" on their project when they realize that they got to rewrite the application all over again.
So I am really hard on OO but I must admit that Object oriented modelling is a nice theory.(...an idealism that does not work in practice).
if u really go into object domain modelling.U will end up with all these things which are really not neccessary...
U have to deal with
A.identity Maps(read objects only once)
B.UnitOfWork(Transaction mechanism for your objects)
C.Topological Sort(To have right insert ,update orders)
D.Mappers(OR/M buy or build it...MS did not do objectspaces which was a cool decision)
E.Repositories(common place to retreive your collections,if u can...)
F.Specification patterns / Query objects(filtering mechanism in objects,functors anonymous methods,POEAA)
G.Metadata Techniques.(some cool SQL reuse that makes the system slow,through code generation or reflection)
H.Design Patterns like FACADE to put everything under the rug...
Do u think is it worth it?
Also at the end of the day,u will face the fact that u need performance.(as the users say so it is Google time!,they just don't wanna wait,time is more valuable than money...)
Carefully looking at your UI code behind,u can easily find out that every user interface in your application has different aspects of data.And there is no ONE most important aspect.(Like u can't love your mum more than your dad...)
Object Models are not build to have many aspects of data as when designing them OO people don't think in a tabular way,they do think in a object way which is slow as their logic is eating RAM and CPU resources which are expensive.They are trying to reinvent the RDBMS idea at runtime.So every VIEW must be differently aligned for your business application user interfaces for performance.
Yes typed dataset approach is not the BEST, but people should also know what they are getting into OR/M world.
The Failure of OO developers is that they are tend to be see OO as a GOLDEN HAMMER.But the business software development has many aspects that,it is not wise to build an "OO Domain Model" where the world is consisted of objects.if u think about it tables are also everywhere in business enviroment.Table is an abstact logic to organize big amounts of business data.Like the simpliest example is;when u go to a train station , u never see OO chart of trains,the thing u see is a table with coloumns and rows telling u where to go and when to go.
I don't mean do not use OO, we should all use OO for some UI staff, but it is just no GOLDEN HAMMER that can solve every problem.LinQ on the other hand is nothing more than an OR/M tool replacing the old idea of objectspaces.(where is it again?...)
So why do I write all these staff , to discourge c# 3.0 team ?
OfCourse not!it is a really nice attempt to try to close the gap between the RDBMS and objects.But the practice and the theory doesn't have to match in daily life of a programmer.
Microsoft should invest time and money in typed datasets, not in OR/M idealism where there is no logical end.
PS: Myth: OR/M vendors might claim if u don't do OO , u will end up with a non adaptable code,spagetti code.
:=) Adaptability is in your head,not in your code...
|
|
|
|
|
Microsoft tries to helping object developers to close the gap between the relational world and the object world.And they call this "object modelling approach" linQ.
Using "custom business entities" in enterprise programming with linQ might seem the best thing after "sliced bread" but it isn't.
For my part I have written my Mappers and used commercial OR/M tools.
They mostly provide the same thing.
__Read the table from the database.
___Put that into a some HELPER thing.(DAO,DAL,ORM)
____Put that into your custom business object
_____Read from your business object.(if u can )
I see NO REASON for this "Unnecessary Pull and Push".
Can anybody explain me why we shouldn't use a typed dataset and go to OR/M?
I hear people saying Typed dataset is really concrete and not flexible to requirement changes.
U even might lose staff when u have to regenerate it.It is far away from perfect.But with typed dataset...
1.U can easily see design time errors + intellisense
2.They also provide rich data for paging,sorting and all kinds of UI staff.
3.For requirement changes,for performance and also for JOINS u should use VIEW's in database modelling.U can also use VIEW's with typed datasets in ADO.net 2.0.really nice graphical component.
On the other hand "object modelling approach" makes NO sense.As to access a group of data,u have to create a custom collection where it is the WORST thing u can do in the business software development in terms of performance.(Arrays are evil).Such as 12 million ORDERS,can have 55 million ORDER_DETAILS and 5 million CUSTOMERS and no LAZYLOADING can help u.Object models use RAM and CPU resources which are really important in terms of performance.if u have more complicated object graph it will be slower.Some might say lets take the performance parameter out and think without it,those people see a "butterfly effect" on their project when they realize that they got to rewrite the application all over again.
So I am really hard on OO but I must admit that Object oriented modelling is a nice theory.(...an idealism that does not work in practice).
if u really go into object domain modelling.U will end up with all these things which are really not neccessary...
U have to deal with
A.identity Maps(read objects only once)
B.UnitOfWork(Transaction mechanism for your objects)
C.Topological Sort(To have right insert ,update orders)
D.Mappers(OR/M buy or build it...MS did not do objectspaces which was a cool decision)
E.Repositories(common place to retreive your collections,if u can...)
F.Specification patterns / Query objects(filtering mechanism in objects,functors anonymous methods,POEAA)
G.Metadata Techniques.(some cool SQL reuse that makes the system slow,through code generation or reflection)
H.Design Patterns like FACADE to put everything under the rug...
Do u think is it worth it?
Also at the end of the day,u will face the fact that u need performance.(as the users say so it is Google time!,they just don't wanna wait,time is more valuable than money...)
Carefully looking at your UI code behind,u can easily find out that every user interface in your application has different aspects of data.And there is no ONE most important aspect.(Like u can't love your mum more than your dad...)
Object Models are not build to have many aspects of data as when designing them OO people don't think in a tabular way,they do think in a object way which is slow as their logic is eating RAM and CPU resources which are expensive.They are trying to reinvent the RDBMS idea at runtime.So every VIEW must be differently aligned for your business application user interfaces for performance.
Yes typed dataset approach is not the BEST, but people should also know what they are getting into OR/M world.
The Failure of OO developers is that they are tend to be see OO as a GOLDEN HAMMER.But the business software development has many aspects that,it is not wise to build an "OO Domain Model" where the world is consisted of objects.if u think about it tables are also everywhere in business enviroment.Table is an abstact logic to organize big amounts of business data.Like the simpliest example is;when u go to a train station , u never see OO chart of trains,the thing u see is a table with coloumns and rows telling u where to go and when to go.
I don't mean do not use OO, we should all use OO for some UI staff, but it is just no GOLDEN HAMMER that can solve every problem.LinQ on the other hand is nothing more than an OR/M tool replacing the old idea of objectspaces.(where is it again?...)
So why do I write all these staff , to discourge c# 3.0 team ?
OfCourse not!it is a really nice attempt to try to close the gap between the RDBMS and objects.But the practice and the theory doesn't have to match in daily life of a programmer.
Microsoft should invest time and money in typed datasets, not in OR/M idealism where there is no logical end.
PS: Myth: OR/M vendors might claim if u don't do OO , u will end up with a non adaptable code,spagetti code.
:=) Adaptability is in your head,not in your code...
|
|
|
|
|
erdsah88 wrote: LinQ on the other hand is nothing more than an OR/M tool replacing the old idea of objectspaces.
Nope. If you attended the last PDC, you'd know that the Linq folks as well as the big heads like Hejlsberg and Box figured out that, after much work with Object Spaces, they decidedly opted for a different approach, and that approach is LINQ.
Firstly, Linq is far more than database queries. In fact, it is general, unified data querying, whether that data is from a database, a collection, an XML file, whatever data you can dig up.
As for DLinq (that is, the database-bindings for LINQ), it is by no means a silver bullet. When combined with anonymous types, you've got yourself a powerful and simple way to query data from a database, but by no means is it a silver bullet. In fact, I'd hesitate to call it an OR/M tool, as it decidely has a different purpose. At the PDC, one of the folks from the audience asked a question similar to what you've said, asking how they can persist objects in a 1-to-1 fashion. The Linq folks responded that is not the purpose of Linq.
The ServerSide.NET has a good article on OR/M mapping[^]. One of my favorite quotes comes from that article, "ORM is the Vietnam of Computer Science; it's damnably easy to get into, and damnably hard to get back out of once you're in it, and you have a tendency to all of a sudden find yourself in the middle of a "situation" that's untenable and hard to live with. (For ORM, frequently this is complex querying, collections, and reporting.) I think Microsoft wants to make sure they've got a clear vision and possible exit strategy before they jump into this quagmire."
|
|
|
|
|
How to invoke from From1 application (it`s the main appliction) to another form (window) with for example cliking the button?
|
|
|
|
|
In your button's click event handler:
frmYourForm oForm = new frmYourForm();
oForm.Show(); // Will show non-modal
oForm.ShowDialog(); // Will show modal
Good luck!
- Doug
|
|
|
|
|
Thanks a lot
I discovered that code:
System.Windows.Forms.Form NewFormObject = new MyForm();
is valid too
|
|
|
|
|