|
|
Nearly one year before I too had posted the same opinion in the lounge. And I was suggesting about an option of including a post like "Unanswered questions of the week" in the lounge every week by admin. But I was voted down.
I also suggested to rank the post before moving into the unanswered category .So It should be moved only if the post has got a minimum cut off mark.
The only thing happened after that is this unanswered answer section.
But still some crooked minds know that the best possible way to get an answer for a tough question is to post it in lounge and they are doing it also.
|
|
|
|
|
jith - iii wrote: the best possible way to get an answer for a tough question is to post it in lounge
No, that will only get your post modded out of the lounge.
|
|
|
|
|
I have seen people coming to lounge after the failed attempts in other forums with the sugar coated versions of their questions.
|
|
|
|
|
First of all, I have HideSelection set to false. I implemented drag and drop in a TreeView so that the indexed cards in the tree can be moved manually (cards store book info like Library card files). An XML file is updated with the newly arranged tree. The TreeView is refreshed in the Drag_Drop event, but the SelectedNode does not show!
Is there a workaround for this?
Here's the code...,
<small>private void cardsTreeView_DragDrop( object sender, DragEventArgs e )
{
nodePosition.X = e.X;
nodePosition.Y = e.Y;
nodePosition = cardsTreeView.PointToClient(nodePosition);
TreeNode dropNode = cardsTreeView.GetNodeAt(nodePosition);
if (dropNode != null && dropNode.Parent == this.nodeToDelete.Parent)
{
TreeNode dragNode = this.nodeToDelete;
if (dropNode == dragNode)
return;
dropNode.Parent.Nodes.Remove(this.nodeToDelete);
dropNode.Parent.Nodes.Insert(dropNode.Index + 1, dragNode);
Cards.MoveCardTo(GetIndexString(dropNode), GetIndexString(nodeToDelete));
Cards.ReOrderCards();
if (cardsTreeView.Nodes.Count > 0)
cardsTreeView.Nodes.Clear();
cardsTreeView.BeginUpdate();
Cards.GetAllCards(ref cardsTreeView);
cardsTreeView.EndUpdate();
cardsTreeView.ExpandAll();
cardsTreeView.EndUpdate();
cardsTreeView.SelectedNode = cardsTreeView.Nodes[dropNode.Index];
cardsTreeView.SelectedNode.EnsureVisible();
}
}
private void cardsTreeView_DragEnter( object sender, DragEventArgs e )
{
if(e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
private void cardsTreeView_ItemDrag( object sender, ItemDragEventArgs e )
{
nodeToDelete = (TreeNode) e.Item;
string strItem = e.Item.ToString();
DoDragDrop(strItem, DragDropEffects.Copy | DragDropEffects.Move);
}
</small>
Thanks,
Mark
|
|
|
|
|
Give this a try. I've noticed that some properties don't seem to update until they are rendered (bad form IMO).
cardsTreeView.SelectedNode = cardsTreeView.Nodes[dropNode.Index]; <br />
cardsTreeView.Nodes[dropNode.Index].EnsureVisible();
|
|
|
|
|
Sorry, but I don't understand your reply. You posted the code that I already have in my project.
Mark
|
|
|
|
|
Ah not quite. Where you set the tree.SelectedNode to someNode, and then called EnsureVisible on tree.SelectedNode , I set the tree.SelectedNode and then called EnsureVisible on someNode.
It might not seem like theres actually a difference, but I have noticed sometimes you can set properties on some of the web controls and they don't come back out correctly until they are rendered. Ie the following code fails:
someTree.selectedNode = someNode;
assert(someTree.selectedNode == someNode);
Odd, I know, but theres no harm trying it.
|
|
|
|
|
Well I tried your suggestion and the TreeView still does not scroll to the selected node and show it as selected. Must be a bug in the TreeView control.
Thanks for the assistance.
Mark
|
|
|
|
|
Hi,
Would anyone explain the meaning of the yellow highlighted code?
I am specifically not sure on what it means as a declaration.
// Constructor that defaults to case-insensitive switches and
// defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
// Constructor that defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
And how would you rewrite it in a simplified way (Easy to read and understand)
Thank you.
Rad
public abstract class ArgumentParser
{
private String[] switchChars; // For example: "/", "-"
private String[] switchSymbols; // Switch character(s)
private Boolean caseSensitiveSwitches; // Are switches case-sensitive?
// Domain of results when processing a command-line argument switch
protected enum SwitchStatus { NoError, Error, ShowUsage };
// Constructor that defaults to case-insensitive switches and
// defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
// Constructor that defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
{
}
// Constructor with no defaults
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars)
{
this.switchSymbols = switchSymbols;
this.caseSensitiveSwitches = caseSensitiveSwitches;
this.switchChars = switchChars;
}
Thanks,
Rad
|
|
|
|
|
radshaykho wrote: Would anyone explain the meaning of the yellow highlighted code?
What yellow highlighted code?
|
|
|
|
|
Colin Angus Mackay wrote: What yellow highlighted code?
Got me on that...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I don't understand your post.
You mentioned some yellow, the only yellow is the NEW sign on the subject line.
It's my guess the class intends to parse command lines, things that take
filenames (or some other objects) plus optional "switches" which start with
a special symbol such as - or / (as is often the case on UNIX/LINUX and Windows).
And then what follows that symbol may or may not be case-insensitive.
Now what is the problem ?
BTW: there are PRE tags to show code with background color and indentation.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
First, you should wrap your code sections in <pre> tags to make them easier to read. Second there was no section highlighted in yellow so everything that follows is based on guessing what you were asking.
public abstract class ArgumentParser
{
private String[] switchChars;
private String[] switchSymbols;
private Boolean caseSensitiveSwitches;
protected enum SwitchStatus { NoError, Error, ShowUsage };
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
{
}
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars)
{
this.switchSymbols = switchSymbols;
this.caseSensitiveSwitches = caseSensitiveSwitches;
this.switchChars = switchChars;
}
} Based on the code presented here, the third constructor (protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars) ) is the one that actually does the work. The other two constructors are overloading the object constructor and providing two additional "short-hand" ways of declaring an instance of the ArgumentParser class that require fewer parameters. The this calls after the function declaration tell the runtime to call that version of the constructor before running any code in the requested constructor. (In this case, there isn't any additional code being run.)
The sequence that happens would be this:
- You call the
ArgumentParser(String[] switchSymbols) constructor, which
- calls the
ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches) constructor, passing in switchSymbols (from your call), false , and the string array { "/", "-" } as the parameters.
- This constructor runs and returns control back to the constructor you called, which
- runs any code contained in it's body (in this case, there isn't any.)
There really isn't a way to make this any simpler other than to remove the overloads and force everyone to call the full constructor; but that isn't really simplifying it.
|
|
|
|
|
I have a pdf file as byte[] coming from ReportingService, it is ok If I want to save it in client PC "Response.BinaryWrite(myReport)";
, but how can I send it as an atachment in email message?
.
.
.
byte[] myReport;
myReport= rs.Render(path,fileFormat, null, @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>", parameter, null, null,
out encoding, out mimeType, out parametersUsed,
out warnings, out streamIds);
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
//this one works ok:
Response.BinaryWrite(myReport);
//but I want to add attachment:
MailMessage em = new MailMessage();
em.Attachments.Add(myReport);//this doesn't work, I need to somehow change the "myReport" byte[] to pdf file
em.From = "myemail@email.com";
em.To = "myemail@email.com";
SmtpMail.SmtpServer = "emailserver";
SmtpMail.Send(em);
vafa
|
|
|
|
|
Create a MemoryStream from the byte data, then create an Attachment object by reading from the MemoryStream .
---
single minded; short sighted; long gone;
|
|
|
|
|
No, you need to covert it back to MemoryStream.
MemoryStream ms = new MemoryStream(myReport);
em.Attachments.Add(new Attachment(ms, [your mime type]));
modified 17-Jul-19 21:02pm.
|
|
|
|
|
ok, thanks for the postings, I could not get it done since I am not using .NET 2
in older version it just accepts the file path, but new one gets the MemoryStream too.
|
|
|
|
|
I would like to create a handler for form.GotFocus(). In VB I would use a procedure created by the IDE:
vb:
Private Sub Form1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
DOIT()
End Sub
How is this reflected in c#?
private void Form1_GotFocus(object sender, EventArgs e)
{
}
Jon
|
|
|
|
|
that seems correct. just add "DOIT();" to the methods body.
What is the problem?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
the problem was finding the command that tells .NET which function handles which event; I had second thoughts and used the EventHandler.
Jon
|
|
|
|
|
OK, I see; as Christian already replied, you add a delegate to the Focus event:
this.Focus+=new EventHandler(Form1_GotFocus);
the nice thing about Visual Studio C# is as soon as you enter the +=
it suggests the remainder of the line; tab twice to accept and automatically
get the handler's skeleton.
Alternatively you can do the same thru Visual Designer (if so, the this.Focus+=
line will appear file in Form1.Designer.cs)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You can do it in the designer, or you can put some code somewhere that says this.Focus += new EventHandler(this.Form1_GotFocus); Something like that.
Yes, I like how VB does it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
I want to create an application that reads the videostream from a webcam, alter the videostream by applying filters, and send the altered stream to an application (like MSN, Skype and other apps that can use cams). To get this to work I guess I have to create an app that reads data from my default webcam, alter the videostream and sends this to a webcam driver that I have created.
In order to let MSN view the altered videostream by default, I need windows to think it has an extra webcam. In MSN it is possible to choose from several cams, and if I can et my "fake" driver to appear in that list, I can send my altered videostream to that driver.
Is this the way to do it? And how can I make this driver? Do I need anything else than WDK?
I'll appreciate all help.
-Martin
|
|
|
|
|
Maybe this holds the key[^]
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|