|
I'm having trouble reading data into a strongly typed dataset from an XmlReader where the data is held as attributes rather than elements. I retrieve two document types and have an XSD for each. One is a standard results document and the other is an error one, formatted as:
results:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<result id="123" generated="3456789" account_id="1">
<field1>FIELD1DATA</field1>
<field2>FIELD2DATA</field2>
<field3 />
</result>
error:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<result error="001" severity="1" message="Record not in database" />
I'm able to populate my dataset from the 'results' XML doc without any problems (and can read the attributes as well) but the 'error' XML doc doesn't populate any rows into the dataset, even though the XSD defines the attributes as data fields:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" id="ResultError" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="result">
<xs:complexType>
<xs:attribute name="error" type="xs:string" />
<xs:attribute name="severity" type="xs:string" />
<xs:attribute name="message" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element msdata:IsDataSet="true" msdata:UseCurrentLocale="true" name="ResultError">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="result" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Can anyone shed any light on this? The worst case I can figure is that the ReadXml() function reads the InnerXml property rather than the OuterXml one and therefore discards the attributes but I can't believe that this is actually right...
Thanks in advance
D
|
|
|
|
|
I have a task to deploy a multistate treenode that will display disabled text if the user is not authorized to modify/view the contents of the treenode item.
I have everything implemented. But I was wondering if anyone knows of the "standard" for displaying disabled text in a control. I assume first off that the text background color = the control background color. But what should the ForeColor be set to? SystemColors.? I was hoping there was a SystemColors.DisabledText.....but no luck. Has anyone done this?
-- modified at 10:37 Friday 21st July, 2006
|
|
|
|
|
Try this
System.Windows.Forms.ControlPaint.DrawStringDisabled()
with color
SystemColors.ControlLightLight
or
SystemColors.Control
Every bit counts
ADD
|
|
|
|
|
Hi all,
is there a simple way to sort dates in a listbox with the dd.mm.yyyy format, so that the dates are shown in correct asscending order ?
tnx
|
|
|
|
|
Sort them prior to populating the listbox, specifically when they're in the DateTime format.
If you get them as strings, then just convert them to DateTime, sort, and then populate the list with the dd.mm.yyyy format of the sorted DateTimes.
|
|
|
|
|
There are many approaches to this request.
One approach is to create your own listbox that takes your own listboxitem. The listboxitem class you define would contain the date as part of the data to display, and your listbox class would do the sort prior to repainting the view each time.
Since ListBox takes and object as its collection, and does the display by calling .ToString() on the object, you can control what the display looks like, the order of the objects, and just about everything else...all while using mostly the base methods.
|
|
|
|
|
Hi ..Condor,
thanks, I think that's a practical way, either the data can change or can be expanded.
tnx
Frank
|
|
|
|
|
Hello,
when I add a custom ToolStripItem (derived as shown below) to a ToolStrip at designtime in Visual Studio 2005, it crashes Visual Studio after ca. 3-4 times adding...although my class works quite well when I add it manually to the ToolStrip at runtime...
This error seems to arise only when I use the DateTimePicker control, with other controls there are no problems...
<br />
[ToolStripItemDesignerAvailability( ToolStripItemDesignerAvailability.ToolStrip)]<br />
public class ToolStripDateTimeItem : ToolStripControlHost<br />
{<br />
public ToolStripDateTimeItem() : base(new DateTimePicker())<br />
{}<br />
}
So here is my question: does anybody got this kind of problem as well...and if so, is there a Service Pack already available for VS 2005 which solves this problem?
-- modified at 10:01 Friday 21st July, 2006
|
|
|
|
|
Best thing to do is to go to http://connect.microsoft.com/VisualStudio[^] and search for the issue, and if not already known, enter a new bug.
If it's really a blocking issue for you - you can't wait for a subsequent service pack, because I think SP1 is now entering final testing - then you'll have to call MS Product Support and see if they can issue you a hotfix. Generally your support call is refunded if a hotfix is issued, although this isn't completely guaranteed.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hello,
I have a TableAdapter, and have SELECT, INSERT, DELETE, and UPDATE stored procedures assigned to it. However, if I use:
<br />
PropertyInfo commandsProperty = type.GetProperty("CommandCollection", BindingFlags.NonPublic | BindingFlags.Instance);<br />
SqlCommand[] commands = (SqlCommand[])commandsProperty.GetValue(tableAdapter, null);<br />
I get only one command item, specifically the SELECT stored procedure. Does anyone know why?
Thank you.
|
|
|
|
|
I believe (haven't actually done it) that it is returning the first command in the collection as the default since you are passing null as the last parameter rather than an array of indexes.
|
|
|
|
|
So how can I reference all my commands in that object array?
Thank you.
|
|
|
|
|
Hi
I want to drive a line to form by a method(not onpaint) and then when i resize or something else it will stay there.But something wrong.
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
Draw();<br />
<br />
}<br />
void Draw()<br />
{<br />
Graphics g = this.CreateGraphics();<br />
g.DrawLine(Pens.Coral, 30, 30, 270, 60);<br />
this.Invalidate();<br />
this.Update();<br />
<br />
}<br />
Here how can i do this.When i call invalidate and update i know that it calls to onpaint event and it draws but after that it calls to onpaintbacckground event and i can not see the line.
If i disable onpaintbackground with this:
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
<br />
}<br />
It doesn't solve my problem.Also i set control setstyles but again it doesn't solve the problem.
1-)What is function of invalidate()
2-)How can i draw a line with a method and it will stay during lifetime of my form.I mean it doesnt change or destroy while resizing or somethin that.(Like writing onpaint event.)
I am looking for your answers
Thanks
|
|
|
|
|
Hold a Bitmap with the size of your form and draw into it:
using (Graphics g = Graphics.FromImage(myBitmap)) {
}
Then in OnPaint just draw this bitmap onto your form:
e.Graphics.DrawImageUnscaled(myBitmap, 0, 0);
Generally speaking controls do not 'remember' what has been painted onto them. Each time they are invalidated (either by code or for example by another window being dragged over them) everything has to be repainted.
|
|
|
|
|
thank you Robert Rohde
if they do not(or can not) remember what has been painted onto them , what is the function of invalidate()?Why do msdn say use invalidate to update form?Where do we use it?
Thanks again
Good works...
|
|
|
|
|
The process of displaying your form is done through the process known as Invalidate(). This is called for just about any reason:
Your mouse moved on the form
A form moved on top of your form
the user resized your form
With any of these events, the Form does some very basic processes to determine if a control must invalidate or if the entire form invalidates. This controls the depth of paint events that occur.
You cannot just draw a line on the form and expect it to be integrated into the rest of the form paint event. The only way of doing this is by doing your own painting. This can be quite a pain if you have to deal with controls as well as just that one line you want to paint.
So then make your task easier:
Create your own user control and name it StaticLineControl. Have the control defined so that you do not care where your control is or where how big the line needs to be. Just do your own painting of a line centered on the control for the width of the control.
Now as a control, your 'line' exists in the proper z-axis in relationship with everything else. You still have just what you need and the work itself is reduced to an e.Graphic.DrawLine() call in your code instead of whatever you are in pain over now.
Remember the K.I.S.S. principal.
|
|
|
|
|
Robert Rohde wrote: Generally speaking controls do not 'remember' what has been painted onto them.
On a completely unrelated, yet interesting, tangent...
WPF uses a retained state rendering technique, which means that your control can explain to the system how it should be rendered once, and, in theory, it will never again for the life of the control. It uses vector-based rendering instructions (sort of like metafile) which are cached by the underlying composition engine!
:josh:
My WPF Blog[^]
|
|
|
|
|
|
Judah Himango wrote: Sounds cool.
It's a brave new world, Judah! The whole HWND system is replaced. Everything has changed.
|
|
|
|
|
Josh Smith wrote: The whole HWND system is replaced
Is that right? Are you sure it's not lurking there under the hood somewhere? I assume it is since it has to interop with Win32 based technologies like Windows Forms, MFC, etc.
|
|
|
|
|
Judah Himango wrote: Is that right? Are you sure it's not lurking there under the hood somewhere?
Positive. The only way that HWNDs are involved is in interop scenarios. Other than that, the HWND has no role in WPF. In fact, if you host an HWND-based control in a WPF application, it is not affected by any transforms, animations, etc. It just sits there like a dork in a Lamborghini.
|
|
|
|
|
Josh Smith wrote: In fact, if you host an HWND-based control in a WPF application, it is not affected by any transforms, animations, etc.
Very interesting. Thanks.
Josh Smith wrote: It just sits there like a dork in a Lamborghini.
LOL!
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I have always been wondering about this subject.
What's the best way to decouple components from different layers?
I have been thinking about a method like the following:
Data access: Components implement interfaces from the Common namespace
Businesslogic: Components refer to the interfaces from the Common namespace
Webservice: Links data access components to the Business logic by assigning them to the right properties (which are typed using the common interfaces).
When not in a distributed environment, you can replace Webservice by a normal servicing layer. It even provides options to make a proxy construction in which the client can choose between the webservice and the local service
Anyone have interesting thoughts on this?
WM.
What about weapons of mass-construction?
|
|
|
|
|
I have been searching the net, the code project en google.
But I just cant find an answer to my question:
I create a ansync sokcet connection adn use BeginRead te read data from the socket.
like this:
private void Receive(){<br />
_Stream.BeginRead(_Buffer, _Offset, _Count, new AsyncCallback( RecieveCallBack ), _Stream);<br />
}<br />
<br />
private void RecieveCallBack( IAsyncResult asyncResult ){<br />
try{<br />
int _ReceivedBytes;<br />
_ReceivedBytes = _Stream.EndRead( asyncResult); <br />
if( _RecievedBytes > 0 )<br />
{<br />
string data = System.Text.Encoding.UTF8.GetString( _Buffer, _Offset, _RecievedBytes);<br />
<br />
FireOnReceive(data);<br />
if ( IsConnected )<br />
Receive();<br />
}<br />
} catch(ObjectDisposedException) {<br />
return;<br />
} catch(System.IO.IOException e) {<br />
FireOnError( new ConnectionException(e.Message , ConnectionErrorType.ReceiveError ) );<br />
}<br />
}
The problem is that it reads only as much as the _Offset allows, this is set 1024 byte.
But if the received is bigger than the offset the socket blocks and i only get half the data i need.
How do I get the complete data form the socket, I looked at some examples on code project bud they all us other method of getting the data form the socket object.
-- modified at 8:29 Friday 21st July, 2006
|
|
|
|
|
Here's a simplified sample for the received callback.
You forgot the resume reading from the stream. This causes the application to stop receiving data. Also you use the offset, this isn't necessary since you simply fill the receive buffer again from the start.
private void dataReceived(IAsyncResult asyncResult) {<br />
_receivedbytes = _stream.EndRead(asyncResult);<br />
<br />
string data = parseData(_buffer,0,_receivedbytes);<br />
<br />
_stream.BeginRead(_buffer,0,_bufferlength,new AsyncCallback(dataReceived));<br />
}
WM.
What about weapons of mass-construction?
-- modified at 8:45 Friday 21st July, 2006
|
|
|
|