|
Well security issues exists for a reason. You might consider just digging in and getting up to speed is a better approach than an unsecured solution.
|
|
|
|
|
I have a usercontrol on a form when i click on the usercontrol I changed the control Style. But my Keydown and KeyPress events are not being fired.
public UserControl1()
{
InitializeComponent();
this.MouseClick += new MouseEventHandler UserControl1_MouseClick);
this.KeyDown += new KeyEventHandler(UserControl1_KeyDown);
this.KeyPress+=new KeyPressEventHandler(UserControl1_KeyPress);
}
void UserControl1_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show("Presss");
}
void UserControl1_MouseClick(object sender, MouseEventArgs e)
{
MessageBox.Show("mouseclick");
this.BorderStyle = BorderStyle.Fixed3D;
}
void UserControl1_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show("down");
}
|
|
|
|
|
The problem you're running into is that you're handling the Key events of the UserControl, which will never have the input focus. The constituent controls of the UserControl get the focus, not the UserControl itself. A UserControl is a container, not a focusable control. This is why the UC keyboard events never fire.
|
|
|
|
|
Thanks for answering but what i want if the usercontrol has focused then listen for keyDown event and keyPress events. How can i achieve this any example please
|
|
|
|
|
netJP12L wrote: what i want if the usercontrol has focused
Not possible. I just told you the UserControl cannot be focused. The constituent controls inside the UC can have the focus, but you'll have to handle the Key events for each of those controls in your UC code.
|
|
|
|
|
Where's PreTranslateMessage() when you need it the most?
--
Raaaaaaaaaaaaaaaaaaaaa!
|
|
|
|
|
I guess it's hiding inside the KeyPreview = true; in the Form class. Too bad it doesn't apply to UserControl.
|
|
|
|
|
Is there a simpler way to load a DataTable from XML where I need to qualify the XML with an XPath? Currently, I have:
DataTable dt=new DataTable();
XmlNodeList nodeList=xdoc.SelectNodes(rootName+"/"+path);
if (nodeList.Count != 0)
{
CreateColumns(dt, nodeList[0]);
}
foreach(XmlNode node in nodeList)
{
DataRow dr=dt.NewRow();
foreach(XmlAttribute attr in node.Attributes)
{
dr[attr.Name]=attr.Value;
}
dt.Rows.Add(dr);
}
Is that the best way to do this?
Marc
|
|
|
|
|
Marc Clifton wrote: Is there a simpler way
Marc Clifton wrote: Is that the best way to do this?
I don't know if simpler or better is how you might describe this but I would think you could work with the XPathNavigator library and derive from XmlReader passing calls on to the navigator so you can use DataTable.ReadXml( XmlReader).
|
|
|
|
|
led mike wrote: I would think you could work with the XPathNavigator
Ah, the XPathNavigator! I forgot about that. Thanks, I'll take a look.
Marc
|
|
|
|
|
|
Hi,
I am no expert on RichTextBox, but the way I understand it is: RTB.Text contains the
text without formatting; and RTB.Rtf contains the RTF representation of the text, including
formatting commands (which is not HTML), so only an RTF-capable receiver would be able
to present it the way you hope.
Maybe your sender app should take the RTF, convert the RTF commands to HTML commands,
then send it.
Hope this helps.
|
|
|
|
|
In the TreeView control, when you expand a parent node, its children "slide" in to view, and "slide" out again when you collapse the parent node. I thought there was a way to stop this, and have the children just appear, rather than slide, but I can't seem to find it. I've tried searching Google for both C# and C++/Win32 examples, but to no avail.
Thanks in advance.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA
|
|
|
|
|
I guess you are running Vista? Because there is no sliding in my tree controls on XP Pro
|
|
|
|
|
If it were only that easy. No, actually, I'm using Windows XP, SP2, with VS.NET 2005, and the standard TreeView control. I should have mentioned (my bad) that it only seems to happen when there are several (say, over 40) children in a node. If there are only a few items, the expand/collapse is instant.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA
|
|
|
|
|
Jamie Nordmeyer wrote: I should have mentioned
umm yeah, that would have helped. But I just made a treeview control with 100 children under the root and there is no sliding when I expand/collapse it. What else did you leave out?
|
|
|
|
|
No clue. Apparently it's another one of those Windows "features" that work for some and not for others... I'll keep looking. Thanks.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA
|
|
|
|
|
Jamie Nordmeyer wrote: No clue. Apparently it's another one of those Windows "features" that work for some and not for others... I'll keep looking. Thanks.
What you're seeing isn't an intentional sliding effect, it's a slow redraw (actually, it's "tearing" - the drawing passes are falling between screen refreshes). All of the nodes below the ones being collapsed have to be moved up and redrawn, and what you're seeing is the redraw versus the refresh rate of your monitor.
There's no sliding. If there were, it would be consistently and always obvious. There's also nothing you can do about it.
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
Greetings,
I am working on a project that is way to big for me, but I thought I would try and tackle it anyway as an opportunity to learn more.
Within my application I am trying to develop a static method that I can use to convert a time such as 1:15 (1 hour 15 minutes) to a decimal.
I understand the formula, since I used it in Excel before. I need to take the input value from the user, pass it to the method, and multiply it by 24. This will give me the decimal value that I need.
My question is strangly simple, and I am still just stumped by it... what data type do I need to use to get my user information into my method? It's just the colon in the user value that throws me off.
Can I just take in "xx:xx" as a string value and then use "Convert.ToDecimal"?
I'm sorry if I am not clear enough. If it's not, let me know and I will be happy to rephrase.
Beginning Programmer - Still learning as much as possible.
|
|
|
|
|
Hi,
if the method is to accept a date, you basically have two choices:
- pass it a DateTime instance
- pass it a string representing a date, and use DateTime.Parse inside the method to decode it
whatever you choose the method will need DateTime.Hours and DateTime.Minutes to calculate
the integer value you want.
I don't expect Decimal type will be of much help.
|
|
|
|
|
Thank you very much! I really appreciate it!
Beginning Programmer - Still learning as much as possible.
|
|
|
|
|
I have a com object dll file called MyCom.dll with some classes, interfaces, methods and events.
I can add it as a reference to my project in visual studio IDE and create an instance from one interface that i need:
MyDllLib.InterfaceName myobject = new MyDllLib.InterfaceName();
I can also access all the events and methods for this interface via myobject.
So by some reason i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events.
If i dont add it as a reference in .Net IDE so i can't reference it.
Could someone recommend the best solution for this.
Thank You,
|
|
|
|
|
Shahin77 wrote: i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events.
Shahin77 wrote: Could someone recommend the best solution for this.
There is no "best solution". Doing this just makes your life so much more difficult, it's not worth it. You've just about trippled the amount of time it'll take to write your code to consume this library, being that you lose all type safety and Intellisense, not to mention that you'll have to write the code to load this library and initialize it. You'll also need to write the code to lookup and instantiate objects, manually wire up events, ..., ..., yada, yada, yada...
Why would you want to ignore all the benefits of early binding and having the compiler do all the dirty work for you??
|
|
|
|
|
The reason is im working on a project which is shared between 20 developers and i dont want to add any reference to the project, I dont want any dependency to this dll file when i compile. So any idea?
Thank You
|
|
|
|
|
There isn't a way around this. The dependancy is GOING to be there no matter if you use a reference or not.
With the reference, you just made using this library about 100x harder to use because now your developers have to write their own code to load the library, init it, lookup and instantiate objects, wire up events, ..., ..., ...
It's simply not worth it. There is no "easy" way around this.
If you've chosen to export your library as a COM-based .DLL, you've also locked yourself into DllHell and the dependancies that come with COM. You simply have no way around this.
Now, if the library is exported as a normal .NET library, the dependancies go away and you can even setup the app's app.config file to redirect dependancies to new version of the library assembly.
|
|
|
|