|
While the second part is true,
SledgeHammer01 wrote: why not just use: [something]
Because it does something entirely different.
|
|
|
|
|
Er, you're right... I just glossed over the example .
|
|
|
|
|
Option A should really be
foreach (Project p in UserProjects.FindAll(x => x.DomainName.Equals(domain)))
{
itemsToShow.Add(p.ProjectName);
}
But I still think B is clearer. Also, why are you using .Equals instead of ==? For almost every class they are equivalent (even if I override Equals for value semantics I also override ==/!= because it's just too confusing otherwise) and == is prettier.
|
|
|
|
|
Thanks for your comments - this was more a general style point rather than the actual semantics of the sample code - I am putting together some new coding standards for a client and wanted to garner your views.
|
|
|
|
|
Hello Developers:
I am new in programming C#, i have a question about handling Usercontrol in win forms. i have started new project, in it i added a menu strip.
Menu have following List of Item:
<b>
New Member
Modify Member
Delete Member</b>
i have add three usercontrol for each of menu items and named them:
<b>
NewMember_UserControl
ModifyMember_UserControl
DeleteMember_UserControl</b>
Now what i want to do is: when i click on the <b>New Member</b> Menu Item, Usercontrol "<b>NewMember_UserControl</b>" display on the Main form's area below the menustrip. and similarly for two others
Please help me in writing menu even handler for UserControl.
|
|
|
|
|
There are a few options. I'm not sure what will bring the best performance:
Note: I assume your usercontrols are more or less the same size?
1.
Add the three usercontrols when the form loads, but make them invisible (or make a default visible and hide the others) In the event handler of the menu item you can then switch visibility accordingly.
I think this will have a good performance, but with higher memory usage.
2.
Add/Remove the controls dynamically from the form. The most easy way is to add a panel that will contain the usercontrol.
You can then do something like mypanel.Controls[0].Add(new ..._UserControl) (and a similar call for remove)
Note that you probably need instantiate an object of the usercontrol and set some properties before adding.
This will be a little slower, but less Memory consuming.
Hope this helps.
V.
|
|
|
|
|
Are you sure you don't want TabPages? Or dialogs?
|
|
|
|
|
anything else on sale today?
PS: you're right to ask, it just sounded a bit mercantile...
|
|
|
|
|
I have a MainMenu on clearance, but I don't think that'll do what he wants.
|
|
|
|
|
This is a repost of [^] on QA Sept. 22. The question was upvoted, and several detailed suggestions presented.
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
I don't know how to Insert image on ricktextbox. Can you help me?
|
|
|
|
|
I needed that functionality not so long ago, and was able to get it up and running, with a lot of help from Google.
It is quite complex, and beyond the scope of a forum message. Here is the gist of it:
- a RichTextBox basically displays whatever is in an RTF document (which can be created using an app such as WordPad, or MS Word; or can be constructed programmatically by obeying the RTF specification).
- AFAIK the only way to have an image in an RTF, is by embedding all the image data using a MetaFile; there are two metafile formats, WMF and EMF, one is easier to construct, the other is what is needed eventually.
- there isn't an all-managed solution; you would need to call some native Windows functions (GdipEmfToWmfBits, DeleteEnhMetaFile), which requires P/Invoke.
The dataflow is like so:
Image -> Graphics -> Metafile(EMF) -> Metafile(WMF) -> RTFdocument
If you feel up to it, you now have a number of essential keywords. Good luck.
|
|
|
|
|
Luc Pattyn wrote: Image -> Graphics -> Metafile(EMF) -> Metafile(WMF) -> RTFdocument
Bloody hell - I'm glad I gave up trying to supply a richtext requirement in Silverlight, I can guarantee if I had I would have ended up dealing with this issue and I choked on the simple formatted text requirement.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I had exactly this requirement and can confirm that what Luc outlines here is the only way (at least, the only way I found) to make it work. You can embed an EMF in a metafile, according to the spec, but neither the RichText nor Word will actually display it.
|
|
|
|
|
BobJanova wrote: but neither the RichText nor Word will actually display it.
Now that is not correct; RichtTextBox, WordPad and Word happily display my programmatically generated RTF tables and images.
Of special interest to me is WordPad being always present in a Windows environment, with pretty much constant functionality over the years, and able to display a lot of things that it doesn't allow you to create interactively; all of this makes it a rather good report viewer, my reports then being RTF files.
|
|
|
|
|
They will happily display an embedded EMF image? I couldn't make them do that, even though according to the spec it is allowed. I had to do what I understood from your first post, use some P/Invoke hackery to get a WMF and embed that instead.
Tables ... ah, tables. It's possible to write a perfectly valid (according to the spec) table that WordPad/RichTextBox won't eat, too. In particular you can't protect a row from leaking formatting information with {\b ... }, you have to use \b ... \b0. And it doesn't respect cell wrapping or auto-size requests, either.
|
|
|
|
|
As I said, I convert the image to a WMF (that is what I use the native GdipEmfToWmfBits for); EMF is just an intermediate step. It works well for images, it works great for charts, assuming you start from a MetaFile, not a Bitmap.
And I tend to use tables as an "easy" way to position and size the images!
|
|
|
|
|
Yep, that's what I had to do. I think you misread my first post in this subthread – it is embedding EMFs that is allowed under the spec but no reader will actually display the result.
My application was producing statistical reports so we actually wanted tables for tabular output, and some of them have enough columns that getting them all onto the paper at a reasonable size involved some serious hand-crafting of column widths.
|
|
|
|
|
OK, I see what you mean; yes it has to be WMF, hence GdipEmfToWmfBits and practicing some P/Invoke.
|
|
|
|
|
We have a need to provide some functionality in the form of a LDAP Listener within our services product. I do not know much about this area, so I am looking for ideas
Our objectives are to:
1) Listen for LDAP Queries from a third party
2) Determine what the query is
We do not have direct access to Active Directory, but instead must make calls to a web service that does the LDAP query to AD on our behalf, hence the need to determine what the query is
3) Carry out the query (to the web service) and provide an LDAP Response to the third party
We would like to do this in code (VB.Net/C#)
|
|
|
|
|
Hi,
I am using sorting feature in multiple columns in a gridview. My gridview sorting is like this:
protected void gView_Sorting(object sender, GridViewSortEventArgs e)
{
try
{
if (this.ParentPortlet.PortletViewState["direction"].ToString() == "")
{
this.ParentPortlet.PortletViewState["direction"] = " ASC";
}
else if (this.ParentPortlet.PortletViewState["direction"].ToString() == " ASC")
{
this.ParentPortlet.PortletViewState["direction"] = " DESC";
}
else if (this.ParentPortlet.PortletViewState["direction"].ToString() == " DESC")
{
this.ParentPortlet.PortletViewState["direction"] = " ASC";
}
}
catch
{
this.ParentPortlet.PortletViewState["direction"] = " DESC";
}
getData(e.SortExpression.ToString(), this.ParentPortlet.PortletViewState["direction"].ToString());
}
I have four columns in the gridview (Name, Date, Location, Cell) and all these columns are sortable. so If i click name, it sorts in desc order and again if i click it, it will sort in asc order which is great. Similar with the other fields. But my problem is If I click the Name, it will sort in desc order. Now If i click Date, it will sort in asc order. Again If I click the Name, it will sort in desc order. Is there any way we can put these sortings independent to each column. Like, If I click Name, it should sort in desc order. Now If I click date, it should sort in desc order. Now again, If i click Name, it should sort in asc order.
Any ideas?
suchita
|
|
|
|
|
Using a Hashtable, or similar structure, to store the sort direction based on column is about the only way to get this done I can think of at the moment
No comment
modified 25-Oct-11 14:45pm.
|
|
|
|
|
Can you point me to any example on this, please?
suchita
|
|
|
|
|
|
Hi,
I don't know about GridView. However I can tell you about WinForms' DataGridView:
1.
if you provide no code at all, it will sort itself as it should; each column remembers its sort direction, and will toggle it every time you hit the column header without having hit another column header.
2.
It does not have a Sorting event (i.e. no pre-Sort), it does have a Sorted event (post-Sort).
BTW: GridViewSortingEventArgs.SortDirection tells you how the GridView is going to be sorted. Either it is column-specific or unique for the entire GridView, I don't know (and MSDN seems not to be clear on this). If it is column-specific, you should just use it; if it is a single bool covering all columns, you need to replace it by one bool per column, a HashTable could help you do that.
|
|
|
|