|
Which methods do i need to override to put myown drawing code in a tree view, for when it is drawing the nodes?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
I have been trying to figure out, and search for how you can override the normal closing operation of a Form when a user hits the 'X' button, so that it just HIDES the form instead.
The closest I found in a forum someplace was they said to override OnClosing if you want to change how to handle the 'X' button default operations.
Like so:
protected override void OnClosing(CancelEventArgs e)
{
this.Hide();
}
However this does not work. The form is still disposed of, and when I try to show the form again I get an exception say just that.
Does anyone know how to do this, or can point me to an article or forum message someplace that explains this?
Thanks in advance...
Aalst
|
|
|
|
|
I think you can override this function:
private const WM_QUIT = &H12
protected override void WndProc(ref Message m)
{
if(m.WParam.ToInt32() == WM_QUIT)
this.Height = 0;
else
base.WndProc(ref m);
}
navinnx
|
|
|
|
|
You are doing right.
Just add e.Cancel = true;
And I swallow a small raisin.
|
|
|
|
|
Stephane,
That did the trick.
Thanks,
Aalst
|
|
|
|
|
I'm trying to use the DataGrid control to edit some data, but I think it must be bound to some data set. Stephane Rodriguez told me in a previous thread that it doesn't need to be, but looking through the docs I found this:
Introduction to the Windows Forms DataGrid Control
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbconIntroductiontotheDataGridControl.htm[^]
Binding Data to the Control
In order for the DataGrid control to work, it should be bound to a data source using the DataSource and DataMember properties at design time or the SetDataBinding method at run time. This binding points the DataGrid to an instantiated data-source object (such as a DataSet or DataTable), with the DataGrid control showing the results of actions that are performed on the data. Most data-specific actions are not performed through the DataGrid, but instead through the data source.
If the data in the bound dataset is updated through any mechanism, the DataGrid control reflects the changes. If the data grid and its table styles and column styles have the ReadOnly property set to false, the data in the dataset can be updated through the DataGrid control.
I could probably create an in memory dataset and bind the control to it (since I don't have a table in my database that corresponds directly (or even similarly) to what will be shown and edited on the table.)
But I have no idea on how to use data sets and similar clases, any pointers??
Or is there a way to use the control unbound? how do I add columns? rows? set the cells' value?
Thanks,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
the .DataSource property need not be bound to a DataSet, it can be bound to any component (a control with bindings) that implements IList. To add columns in the DataGrid, you also must derive the base class because the CreateGridColumn() is marked protected. Well honestly, I have been playing with this, and I admit that it does not result in simply usable code as it sounded at first sight.
The other option, much seamless, is to create an instance of DataSet, and fill it by loading Xml Data. This means that your data must be first saved as Xml.
All in all, none of the approaches are really worth it, I was convinced that it would have been simpler. Just forget it,
And I swallow a small raisin.
|
|
|
|
|
StephaneRodriguez wrote:
All in all, none of the approaches are really worth it
I was playing with it yesterday before going to bed, and I got something pretty good going on. I created manually a dataset, then a table in it, and some columns (product code, price, description, unit price, price).
Then I created a grid table style (or whatever is called) and added 5 columns mapping to the table columns, with localized text and making the last three readonly.
On the CurrentCellChanged event, I walk every row in the dataset.Tables[0].Rows collection and for each product code, fill in the description and price. If there is a row without product code, I remove the row.
At the end, when I want to get the data, I just enumerate the rows again in the table in the data set and that's it.
I admit it's not as straight forward as I would have thought, but in all it took me about 150 lines of code and two or three hours, so it's not that much either.
I even wrote a little test app (I didn't want to start everything in my real application), and if you're interested I could e-mail it to you. It still has some little bugs (it does not work exactly as I wish it worked) but they don't seem hard to fix.
Thanks very much!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
I load in an xml document and validate it ... ok thats the easy part
XmlDocument doc = new XmlDocument();
XmlTextReader tr = new XmlTextReader("Sample.xml");
XmlValidatingReader reader = new XmlValidatingReader(tr);
doc.Load(reader);
there might be several schemas that are used to validate, their location is specified via the xml schemalocation attribute.
Now if I want a table of those locations i presently read and parse the location attribute and manually match up the namespace prefix with the location file via the namespace URI. So i can go and physically read in the validating schemas.
XmlNode myNode = oc.SelectSingleNode("//instance:group",xmlnsmgr);
XmlNodeReader myreader = new XmlNodeReader(myNode);
myreader.Read();
myreader.MoveToAttribute("schemaLocation",this.xml_schema_ns);
String[] schemalist = myreader.Value.Split(new char[] {' '});
The must be a simplier way I dont know about, please if anybody knows can the enlighten me.
Thanks in Advance
James
|
|
|
|
|
please provide the link of different comprehancive examples of com and com+
and a little help how to run it?
r00d0034@yahoo.com
|
|
|
|
|
C# isn't COM or COM+. You can use it through COM Interop in .NET, but you would more likely ask this in the C++ forum.
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
Hi!
I have to use Microsoft Webbrowser AcitveX control in my program.
I'm coding in C#.
I also used this in MFC and it was just fine.
The BeforeNavigate2, and FileDownload events don't work when I use C# and .NET.
These events are not caught.
What is the problem?
Is there a solution for this??
Please, if you know the answer drop me an email.
Thanks.
|
|
|
|
|
Short answer : SyncFusion web browser own interop. Download htmlviewer.zip. There are two samples :
- HtmlViewer2 is useless (applies a .css stylesheet over an html body, using the AxInterop obtained from aximp on the IE ocx).
- HtmlViewer is useful and great : they do their own interop. That's a little tricky, but you don't need to understand the plumbering. In fact, they replace the OnBeforeNavigate2 and OnNavigateComplete events by two new events declared in BrowserNavigateEvent.cs, and used in Form1.cs (a demo app).
That's really funky stuff from the guys of Syncfusion. Hope it helps,
And I swallow a small raisin.
|
|
|
|
|
|
I have two programs, A and B... program A serializes some data into a buffer, attaches via a socket connection to program B, transmits the serialized data via socket to program B, program B then deserializes the data and all is fine. This process works great if programs A and B communicate on the same machine using the following code to obtain the IP Address:
m_ipHostInfo = Dns.Resolve(Dns.GetHostName());
However, if you obtain the IP Address in this manner:
m_ipHostInfo = Dns.Resolve("www.anyplace.com");
... the deserialization fails in program B, complaining about an invalid header or object version difference...
The data is indeed making it from program A to program B by resolving the DNS for the domain, it just seems like it is getting corrupted in some way.
Any suggestions?
Thanks!
|
|
|
|
|
Are you using network streams to transmit the serialized class?
Could you serialize it to a file and then send the file across and then do a check on the file to see if it is the same?
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
I am using async sockets:
private void SendBinary(Socket sock, byte[] buffer)
{
sock.BeginSend(buffer, 0, buffer.Length, 0,
new AsyncCallback(SendBufferCallback), sock);
}
private void SendBufferCallback(IAsyncResult ar)
{
Socket sock = (Socket)ar.AsyncState;
int nBytes = sock.EndSend(ar);
sendDone.Set();
}
I can try to serialize it to a file on the send and receive sides and see what the differences are... if I find differences (which I should), then what do you think the problem is?
|
|
|
|
|
Why do you think you will find differences. It's just copying the byte stream across the sockets. Thus it should be just the same, right?
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
I added code to write out a file of the buffer prior to sending from the client. I also wrote out a file of the buffer received on the host/server via the socket connection. The buffer on the host is larger than the client buffer. I am investigating the differences now... any clues?
|
|
|
|
|
dwebster wrote:
The buffer on the host is larger than the client buffer.
That's the problem. If you have a bigger buffer transmitting to a smaller buffer then some of the first buffer will get chopped off. That is probably why you can't deserialize the class; it's not whole and intact when you try to deserialize it. Can you increase the buffer size on the client?
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
Actually... Program A (the client) is sending to program B (the host/server) and program B (the host/server) winds up having a larger buffer than program A (the client). Also, remember that the buffers are just fine when using Dns.GetHostName() rather than www.anywhere.com to obtain the IP Address... there is some difference in sending the buffer via sockets to the localhost versus sending the buffer via sockets through the internet (using DNS to resolve)...
|
|
|
|
|
Okay. Scrap the buffer theory. Can you look at the actual data that the program is sending over. If you write it to a binary file, then VS.NET can read it...
If there is just "extra" information in the hosts copy of the class, then you could just trim the buffer...
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
ive overrided the drawItem method in my control [derived from ListBox] and wen i insert it into the designer, it moans about the OnDrawItem method, and i just wondered if there was anything special i was supposed to put in it
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
I asked about one or two weeks ago about how could I get the value of an autonumber filed in the record I had just inserted in one step. Several proposed using @@IDENTITY in a second step.
There's a way to do it in one step:
http://www.4guysfromrolla.com/webtech/tips/t122600-1.shtml[^]
I did it like this in C#:
string sSQL = "INSERT INTO Customers (FirstName, LastName) VALUES (' ', ' '); SELECT @@IDENTITY;";
OleDbCommand oCmd = new OleDbCommand(sSQL, oConn);
oCmd = new OleDbCommand(sSQL, oConn);
nCustomerID = Convert.ToInt32(oCmd.ExecuteScalar().ToString());
Hope it helps someone else!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Hi all,
How does one assign a property or a member or a string to be the value that is shown in the auto's and local windows? I thought this was ToString() but that doesnt seem to work. I also cant seem to find an Attribute doing this...
I'm particularly interested in "naming" delegated methods. Dont know if this is the same as above?
Any suggestions?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|