|
|
And to be safe you really need to fully test it.
|
|
|
|
|
Microsoft has a very good track record when it comes to backward compatibility. So, it must work barring some minor issues. Check the link in the first answer for known issues.
|
|
|
|
|
Mostly, but some things have been obsolesced, which makes developing for multiple versions difficult.
One example:
Reader = new System.Xml.XmlReaderSettings()
{
ValidationType = System.Xml.ValidationType.Schema
,
# if DotNet_2_0 || DotNet_3_0 || DotNet_3_5
ProhibitDtd = false
# endif
# if DotNet_4_0
DtdProcessing = System.Xml.DtdProcessing.Parse
# endif
,
XmlResolver = new System.Xml.XmlUrlResolver()
{
Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
}
} ;
And unfortunately there are no built-in macroes defined for the version so you have to define your own. 
|
|
|
|
|
Hi Guys,
I have a PictureBox control in a WinForms application where I need to display the image at the maximum height allowable by the screen size without changing the image's height to width relationship.
The Picture box is docked to the right of the form. Setting the image height is easy enough but calculating the width is problematic as screen pixels aren't square.
How can I calculate the width with the image displayed to it's maximum height without distorting the image? I don't know the actual screen measurements; only the resolution.
Thanks......
|
|
|
|
|
Have you tried setting the PictureBox's SizeMode property to Zoom??
|
|
|
|
|
I don't think you can unless the height to width ratio of the picture box exactly matches that of the image. Your resulting image will either be distorted or too wide/narrow for the picture box. This article[^] explains the issue and offers a solution which may help you; the code is C++ but should be easy to understand.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
PictureBoxSizeMode.Zoom will perform an isotropic rescale such that the image fits one or both dimensions of the PB without clipping.
MSDN explains it rather well here[^].
|
|
|
|
|
Thanks; isn't it just so easy in C#?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks. The solution shown in the C++ article shows how to size the image and then it's just a matter of setting the PictureBox ClientSize to the image size. This seems to size the image correctly and maintains the ratio.
|
|
|
|
|
And, as Luc pointed out above, the PictureBox looks after things automatically.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yeah, it's about the only useful feature it offers.
I can't understand why people insist on painting on top of a PB, then find it difficult to correlate mouse location with picture pixels.
|
|
|
|
|
Probably because they don't make proper use of the documentation.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi All,
I have an array of UserRights (class that holds the rights for an individual table) called arrTables and an array of controls called arrControls (10 of each type of control needed). The arrControls are displayed/listed on a Windows form (TableName, ViewRights, EditRights...) so that the data for 10 tables can be viewed at one time. I've bound the data to the form controls using the following code:
for (int iLoop = 0; iLoop < 10; iLoop++)
{
ctrlQAControls[iLoop, 0].DataBindings.Clear();
ctrlQAControls[iLoop, 0].DataBindings.Add(new Binding("Text", arrTables, "TableName"));
currencyMgr.Position++;
}
When I try and display the form to the user data from the 10th table stored in the arrTables array is displayed in all 10 sets of controls. I learnt that the CurrencyManager holds the value of the Current possition and that is the reason for these results.
Is there a way around or an alternative way to implement this without hacing to use a datGridView or other list control?
Thank you
|
|
|
|
|
It sounds as though you should be using a view of the data instead of binding to 10 different datasource all at once.
But since you appear to want 10 seperate data navigations going on at the same time you'd use 10 BindingSource objects, each having its DataSource property set to the table you want it to navigate over, then set each controls DataSource property to the BindingSource it should be using.
|
|
|
|
|
Hi Dave,
Thank you for your reply. I've attempted to follow the steps above only the array of controls doesn't have a DataSource method, so I'm unable to set the DataSource of the controls in the array to a BindingSource. Here is what I have:
BindingSource bs1 = new BindingSource();
bs1.DataSource = arrTables;
ctrlQAControls[0, 0].?!?;
Could you tell me how I would go about assigning each controls DataSource property, in the array to a given BindingSource?
Thank you
|
|
|
|
|
If you want to have 10 separate controls each bound to one of the 10 model objects, then you don't need to bother with a currency manager:
for (int iLoop = 0; iLoop < 10; iLoop++)
{
ctrlQAControls[iLoop, 0].DataBindings.Clear();
ctrlQAControls[iLoop, 0].DataBindings.Add(new Binding("Text", arrTables[iLoop], "TableName"));
}
This does seem like a situation where you should be binding to some sort of list control though.
PS you should ditch the Hungarian type naming when you're writing C# code.
|
|
|
|
|
Hi Dave/Bob,
Thank you both for your feedback. I'm going to try the BindingSource objects recomendation now.
Bob- the method you sujected, does this take into account that there are more than 10 objects that need to be binded to the controls? There will be 10 objects bound at any one time, but then I have next and previous buttons to display the next and previous 10 objects.
Thank you again
|
|
|
|
|
Hi guys,
The question is of pure interest: how do you prefer naming a variable/parameter of type Object ?
Most of the time it depends upon the logic of its usage, but not always. Sometimes you just want to express a generic entity:
public byte[] Encrypt(Object x)
public byte[] Serialize(Object o)
Its tempting to name x as obj or objToEncrypt , but it sounds more like a Hungarian notation.
So how would you consider naming it?
|
|
|
|
|
|
Thanks for suggestion,
I was always tempted to append "to". In that case it would be toEncrypt . But it scratches my ear badly. I really like encrypt but its a verb, and it breaks the convention a little.
As for your CommandDoSomething.DoSomething example. I might have misunderstood you, but I prefer not appending action name to class name or viceversa:
User client = User.Create();
User client = User.CreateUser();
Anyway, I believe its a matter of preference
Regards
|
|
|
|
|
I like to
<pre lang="c#">pub byte[] Encrypt(object aValue)</pre>
where a is for argument
I usually do this for class members
<pre lang="c#">int iVariableName</pre>
<pre lang="c#">string sVariableName</pre>
<pre lang="c#">byte [] byData</pre>
sometimes ill append an 's' to arrays
<pre lang="c#">string [] sNames</pre>
Common .net objects I like to turn to an acronym
FolderBrowserDialog - fbd
SaveFileDialog - sfd
StringBuilder - sb
Socket - soc or cli
The result of a method is usually called result no matter what type.
|
|
|
|
|
The only time I even append a type to an object name is when I'm naming controls. For example, Building_TextBox or Building_ComboBox. It comes in handy if you have a couple of controls related to the same thing.
|
|
|
|
|
public byte[] Encrypt(Object sourceObject)
public byte[] Serialize(Object sourceOject)
..although that would make 'em hard to distinguish from local variables.
public byte[] Encrypt(Object AsourceObject)
public byte[] Serialize(Object AsourceOject)
The prefix stands for "Argument", but "Parameter" would be just as effective
This gives you an assigment statement like
byte[] b = Encrypt(AsourceObject := ObjectThatWouldbeSerialized);
Bastard Programmer from Hell
|
|
|
|
|
Cool stuff, like the sourceObject solution. Though, just source sounds even better.
|
|
|
|