|
Thanks!! "CategoryAttribute" was one I wasn't familiar with...
~Steve
|
|
|
|
|
You should take a look at the classes in the System.ComponentModel namespace for more helpful design-time attributes and more. A good section to read if you're new to design-time extensibility is Enchancing Design-Time Support[^] in the .NET Framework SDK documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Great stuff! Thanks Health and Nick. Yes, I'm new to .NET entirely, and am very impressed with what I'm seeing so far. Thanks for the tips and pointers...
~Steve
|
|
|
|
|
I have seen a document somewhere I can design the window form shape to be circular, instead of traditional rectangle shape. Can anyone help? I'm thinking of making this round shape for about box. Something unique.
That's in Visual.net C# language. Thanks!
Ron Boucher
|
|
|
|
|
This uses a clipping region that works with all Windows. See the Graphics.Clip property in the .NET Framework SDK.
One Windows 2000 and newer, you can also use alpha blending and transparent colors. For example, you can set the BackColor of many controls to Color.Transparent . You can also use an image with alpha blending in many cases. Again, though, this is only supported on Windows 2000 and newer NT-based OSes.
Another thing you should check out is the RegionMaster Controls[^] on WindowsForms.net. This is written by a Microsoftie, though not supported officially by Microsoft. It was featured in MSDN TV some time back and is very nice. This aleviates the work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I basically create a dataset and read in a schema file into the dataset. Then when done saving a record to the dataset I save to file as diffgram. When I come back in and recreate the dataset I need to find a particular record that is in the dataset. I do this with the following
code:
<code>
private void FindTodaysDSRec()
{
string sDate, sRecFind;
DateTime dDate = DateTime.Now;
dDate = dDate.AddDays(-1);
// sDate = dDate.ToString("d", DateTimeFormatInfo.InvariantInfo);
sDate = @"12/1/2003";
sRecFind = "MR_Date = " + sDate ;
nRow2 = dsDiff.Tables["MN"].Select(sRecFind);
}
</code>
The record I am looking for exists in dataset but I get a nullrefexception on the select statement.
Here is what the MR_Date is represented as in the schema file:
<code>
<xs:element name="MR_Date" type="xs:dateTime" msdata:AutoIncrement="false" />
</code>
Here is what is in the diffgram:
<b><small>
<Table diffgr:id="Table1" msdata:rowOrder="0"><MR_ID>110</MR_ID><MR_Date>2003-12-01T00:00:00.0000000-05:00<MR_Date>
</small></b>
The sDate statement in the select looks like this:
sDate = "MR_Date = 12/1/2003"
So what am I doing wrong with my select clause in code above?
Thanks,
JJ
|
|
|
|
|
There is no table called "MN", so your dsDiff.Tables["MN"] is returning null . This is the kind of check you should make before calling methods on an object when you're not sure if you'll get an instance or not.
When you read-in your DiffGram, make sure you read the XML Schema first (or just use a typed DataSet ) and use ReadXml("somefile.xml", XmlReadMode.DiffGram) since the file is formatted differently than how a DataSet is serialized normally.
Also, make sure you read the schema before writing your DiffGram. I noticed that the DiffGram table ID is "Table1". The same schema must also be used for both WriteXml and ReadXml .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
I did what you said, read in the schema first then the xml diffgram file. This goes smoothly but as soon as I hit new row on dataset I get the nullrefexception. I named the table statement as "Table1" too. Here's my schema file and xml file maybe u can see something I don't:
<code>
<b>XML Diff File</b>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Table1><Table diffgr:id="Table1" msdata:rowOrder="0">
<MR_ID>110</MR_ID>
<MR_Date>2003-12-01T00:00:00.0000000-05:00</MR_Date>
<Coal_Feeder_Tot>690058</Coal_Feeder_Tot>
<Coal_Silo_Level_Prct>73</Coal_Silo_Level_Prct>
<Coal_Barn_Inv_Prct>25</Coal_Barn_Inv_Prct>
<Limestone_Feed_Total>171316</Limestone_Feed_Total>
<LS_Silo_Level_Prct>70</LS_Silo_Level_Prct>
<Ammonia_Totalizer>388974</Ammonia_Totalizer>
<Prop_to_Burn_Totalizer>14629</Prop_to_Burn_Totalizer>
<TwentyFourHr_SO2_Reduct>92</TwentyFourHr_SO2_Reduct>
<Limestone_Received>40800.37</Limestone_Received>
<Ammonia_Received>0</Ammonia_Received>
<Prop_Received>9004</Prop_Received>
<Est_hours_Dry_Oper_Hours>0</Est_hours_Dry_Oper_Hours>
<LAB_Sulfur_Content_Prct>2.13</LAB_Sulfur_Content_Prct>
<LAB_High_Heat_Val>6833</LAB_High_Heat_Val>
<CEMS_SO2_Daily_Avg>549</CEMS_SO2_Daily_Avg>
<Raw_Water_Pump_Meter>15795967</Raw_Water_Pump_Meter>
<Reservoir_Level>1844</Reservoir_Level>
<Date_Rec_Added>2003-12-08T08:47:15.0000000-05:00</Date_Rec_Added>
</Table>
</Table1>
</diffgr:diffgram>
<b>Schema</b>
<?xml version="1.0" standalone="yes"?>
<xs:schema id="Table1" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Table1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="MR_ID" type="xs:long" minOccurs="0" />
<xs:element name="MR_Date" type="xs:dateTime" minOccurs="0" />
<xs:element name="Coal_Feeder_Tot" type="xs:decimal" minOccurs="0" />
<xs:element name="Coal_Silo_Level_Prct" type="xs:decimal" minOccurs="0" />
<xs:element name="Coal_Barn_Inv_Prct" type="xs:decimal" minOccurs="0" />
<xs:element name="Limestone_Feed_Total" type="xs:decimal" minOccurs="0" />
<xs:element name="LS_Silo_Level_Prct" type="xs:decimal" minOccurs="0" />
<xs:element name="Ammonia_Totalizer" type="xs:decimal" minOccurs="0" />
<xs:element name="Prop_to_Burn_Totalizer" type="xs:decimal" minOccurs="0" />
<xs:element name="TwentyFourHr_SO2_Reduct" type="xs:decimal" minOccurs="0" />
<xs:element name="Limestone_Received" type="xs:decimal" minOccurs="0" />
<xs:element name="Ammonia_Received" type="xs:decimal" minOccurs="0" />
<xs:element name="Prop_Received" type="xs:decimal" minOccurs="0" />
<xs:element name="Est_hours_Dry_Oper_Hours" type="xs:int" minOccurs="0" />
<xs:element name="Est_hours_Dry_Oper_Mins" type="xs:int" minOccurs="0" />
<xs:element name="LAB_Sulfur_Content_Prct" type="xs:decimal" minOccurs="0" />
<xs:element name="LAB_High_Heat_Val" type="xs:decimal" minOccurs="0" />
<xs:element name="CEMS_SO2_Daily_Avg" type="xs:int" minOccurs="0" />
<xs:element name="SO2_Daily" type="xs:decimal" minOccurs="0" />
<xs:element name="Raw_Water_Pump_Meter" type="xs:decimal" minOccurs="0" />
<xs:element name="Reservoir_Level" type="xs:decimal" minOccurs="0" />
<xs:element name="Comments" type="xs:string" minOccurs="0" />
<xs:element name="Date_Rec_Added" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
</code>
This is the line it errors on :
nRow = dsDiff.Tables["Table1"].NewRow();
Thanks,
JJ
|
|
|
|
|
No, actually you called your DataSet "Table1", which I noticed in your previous post. Your DataTable is named "Table". The DataSet element is the root node of your DataSet , the child nodes is/are the DataTable (s), and their children are the fields in a row of the table.
So, dsDiff.Tables["Table"].NewRow(); would work, but you really should name your DataSet and DataTable appropriately according to your needs.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
This is driving me crazy. I have a double variable that has taken a value very close to zero. I try to put the value on the console as
double noiseMean;
Console.WriteLine(noiseMean);
It displays the value in the scientific notation. How can I tell it to display it as the decimal notation. I tried using noiseMean.ToString(), but it always frmats it in the same notation.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
|
Hi,
Thanks for the reply. However, it still throws out the variable in the scientific notation.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hi,
You pointed me in the right direction though. Just saw the section on format specifiers. "d" is for integral datatypes only. Using "f15", basically fixed point with 15 as the precision specifier did the trick.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
The format specifier "d" or "D" will always throw a FormatException for certain primatives like double .
Instead, use Console.WriteLine("{0:f}", 0.0000000001d); , for example. This defaults to two decimal places. If you want more, specify the precision after "f", like so:
Console.WriteLine("{0:f8}", 0.0000000001d); The result here will be the same, of course: 0. You can change the precision how you see fit, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Woops, you got me on that one. I blame it on only having Visual Studio 6.0 in front of me as I typed my response, err, if you want to call that an excuse.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi there,
I'm only a newbie in C# and I have some problems with screen resolution.
I can't find a way to resize my forms (and controls within them) when I change screen resolutions. I'm coding on a system with 1280x1024 resolution and, when I execute the program on my notebook, that's 1024x768, forms stretch and controls often "change position" and move beyond form border.
How can I solve this problem building resolution-independent forms? Do you know some FREE controls that resize automatically my forms (i.e. XSizer -> shareware) or how to code a simple control that does this job?
Thanks.;)
Max
|
|
|
|
|
The actual resolution isn't as much of a big deal as the DPI (dot per inch, sometimes called PPI, or pixels per inch). As far as the size of the forms, you can use the Anchor and Dock properties of any Control (though some may override it or choose to ignore them).If you anchor a control to opposing edges, it will always be resized so that the original margin between the sides of the control and it's container (the sides that were anchored) is maintained. If you don't want that, don't anchor opposing sides. You can also use anchoring to move controls, like an OK button that should always be in the lower-right corner.
Docking works in a similar fashion, but keeps the control docked to a single edge or all four edges.
As far as the DPI changing, that's a different matter. Since pixels are logical units and Windows Forms uses pixels, your layout can't be gauranteed under a different DPI. VB6 got around this by using twips, which is a physical unit and should always look the same on any display.
Laptops these days are typically using 120 DPI while desktops are still using 96 DPI (though many flat panel users are using 120 DPI as well).
You can handle the Microsoft.Win32.SystemEvents.DisplaySettingsChanged event to get notification when either the resolution, color depth, DPI, or any other display setting changes. You can also write a transformation class as I've shown in a previous discussion about this a few days ago: http://www.codeproject.com/script/comments/forums.asp?msg=829941&forumid=1649&Page=3&userid=46969&mode=all#xx829941xx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you man...
I'll try with Dock and Anchor properties...finally I can start to code a "real" program.
Thank you again!
Bye.
Max
|
|
|
|
|
I am writing a small custom win form control (i.e. UserControl). I would like to pop up a wizard the first time the user places the control on a windows form. I cannot figure out how to tell the first time a control is places??? I cannot seem to find any methods or properties in the designer class. Can anyone help here? Thanks!
|
|
|
|
|
Implement a ControlDesigner for your class and attribute your UserControl with the DesignerAttribute specifying the Type or type string for the designer class. In your implementation of Initialize or OnSetComponentDefaults , you could pop up a wizard dialog or whatever you want.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone know what is equivelent of "strstr" in VC# ? Thanks.
|
|
|
|
|
See String.IndexOf and related methods in the .NET Framework SDK documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You can use the IndexOf method of the string class, of course it does not return a pointer like strstr does.
|
|
|
|
|
|
Background:
I'm trying to write a media player that supports various file and playlist types, cd ripping, format conversion, etc. Pretty standard "media player" stuff really.
The first task is to enable playback.
Issues:
I've downloaded the DirectX SDK Summer 2003 update, and audio/video playback is supported by using C#. This rather simple playback however, and not what I'm looking for. I also noticed that DirectShow cannot be used directly by C#, and I have looked at several code snippets using Interop. Allthough Interop will give me the results I'm looking for, the approach to get those results using Interop ar not to my liking.
Possible solutions:
- Anyone know if there will be "managed directshow" for C#? I noticed in the DirectX SDK that they write "This is preliminary documentation and is subject to change." on almost every topic I searched on.
- Learn C++. This would be a solution that I know would work, I would like to use C# though.
- Create C++ backend dll's for the complex work and C# for interface etc... This is just a thought, I haven't found any articles actually building applications this way.
Last words:
Right now, the media player is a bunch of notes on a paper, and I would really like your thoughts/ideas/input on multimedia in C#.
-thorbeck
"Computers are stupid,
they can only give you answers."
picasso
|
|
|
|