|
how can i capture mouse position when my app it's not active?
|
|
|
|
|
Setup a Windows Hook, there are articles on how to do this on this website.
|
|
|
|
|
I am trying to write some some methods which will apply the System.Math methods to arrays instead of individual variables. I thought I might try a generic method (my attempt is below).
public static T[] Abs<T>(T[] array)
{
T[] absArray = array;
for (int i = 0; i < array.GetLength(0); i++)
{
absArray[i] = Math.Abs(absArray[i]);
}
return absArray;
}
The problem comes with the actual call the Math.Abs. The compiler complains:
Error 56 The best overloaded method match for 'System.Math.Abs(sbyte)' has some invalid arguments
Error 57 Argument '1': cannot convert from 'T' to 'sbyte'
Since the compiler doesn't know what type T is, I understand what is happening, but is there a way to make this work (or a better way to do this)?
I was just trying to keep from having to write several identical overloaded methods with differing types (and learn something in the process).
___________________
Brad
|
|
|
|
|
I don't think you can do it this way, T can be anything (int, float, bool, ...). You may have to write a function to get the type of the object and return the object as (int, float, sbyte,... )
|
|
|
|
|
I was afraid that was the answer. If only the System.Math methods were generic...
There isn't any interface that the numeric structs share so that you could specify the array by some interface, either. Oh, well. Lot's of overloads.
Thanks
___________________
Brad
|
|
|
|
|
Hi All
I,m creating an application managing files with custom extension.
I would like that clicking on them the C# application I'm developing starts, read them and execute a task.
I know that the file type should be registered but how to do that in C#?
There is some trick or better way to do it?
regards
Manu Stone
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
Hi,
I have records with thousands of data which I am binding to DataGridView control. Can I display some data initially and then in background process it fills grid with other data and user do not have to wait for filling all the data and then get control of the form.
Thanks in advance.
Kshitij
|
|
|
|
|
Kshitij Patel wrote: Can I display some data initially and then in background process it
Use, use the DataGridView.VirtualMode property, in it you specify how you want the data to be viewed, like displaying only 10 records, and when the user click on the next button, the next 10 will be loaded, this approach is faster than 1000% in large data records.
|
|
|
|
|
Hi,
I am getting mad. I am building my project with VS.net 2005.
When i build the solution all the button, group box... are display in a "Square" look instead of the normal "Rounded".
Is there an option some where that would allow me to do that.
thanks
|
|
|
|
|
I'm not sure what your talking about, but what I am thinking about as 'square' vs 'rounded' may be the difference in your OS settings on XP to look either like WinXP or like Win2K. These settings are set per user and not by your compiler.
If I'm way off can you describe more?
|
|
|
|
|
Yes This is what i mean by square => win2k and Rounded for XP.
But it's seems that you must be able to build an app that will look like an 2K on a XP PC.
My pc is in XP and all my app build look like a XP app but, that one when i build it it, look like a 2K one.
There must be something on the project that make it build it like that...any idear
|
|
|
|
|
In your Program.cs (or whatever your startup is), you have to enable visual styles. Something like this:
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thanks,
that did the job.
|
|
|
|
|
Hey All,
My problem is that sending XML from a web service to client works fine. Using the exact same steps to send that XML back causes a crash!
The web service returns the xml string
<br />
DataSet dsReturn;<br />
...<br />
returnWriter = new StringWriter();<br />
dsReturn.WriteXml(returnWriter, XmlWriteMode.WriteSchema);<br />
return returnWriter.ToString();<br />
The client reads the xml string
<br />
DataSet Budget;<br />
...<br />
srWebService = new StringReader(m_wsBudget.Select("SelectWorksheetbyYearMediaCategory", sYear + "," + sMedia + "," + sCategory));<br />
xmltrWebService = new XmlTextReader(srWebService);<br />
xmlrsService = new XmlReaderSettings();<br />
xmlrWebService = XmlReader.Create(xmltrWebService, xmlrsService);<br />
Budget.ReadXml(xmlrWebService);<br />
This interaction works fine all the time. Using the exact same steps to send that XML back to the web service crashes. For the sake of testing, both Web Service and Client are on the same computer (my development machine).
The exception is:
System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: Comment, HeaderModify, NewDataSet. Line 525, position 31.
This follows immediately after a '#' character in the Comment field of a datatable.
Any advice as to why it works coming from the web service but not sending to it (the Comment field never changed)? Is there another way to easily wrap up the XML from a dataset properly? I would assume .WriteXML() would take care of formatting special characters automatically
Thanks,
Pualee
|
|
|
|
|
|
You can copy and paste from Visual Studio into a RichText control and the formatting is preserved, if you copy & paste into Word you can then save as HTML.
|
|
|
|
|
i have no idea what to name this to. but anyway, i hope i can get some help
i have a while loop which shall go through a few textboxes
the textboxes are named textBox1, textBox2
my code is following
int count = 0;
while(blah) {
count++;
textBox???.Text = "blah";
}
I want to dynamically set the different textboxes with different values, the while loop should through textbox1, textbox2 and so on.
how do i make that?
i hope i explained myself good enough
|
|
|
|
|
Why You are using this while loop.......
You can add all the textboxes to a panel or groupbox then you can use the foreach method like
foreach(TextBox txtbox in panelTextBoxes.Controls)
{
txtbox.Text = " ";
}
My small attempt...
|
|
|
|
|
Place each of your textboxes in an Array and set them that way.
TextBox [] tbArray = new TextBox[] { this.textBox1, this.textBox2 };<br />
int count = 0;<br />
while(blah)<br />
{<br />
tbArray[count].Text = "Blah";<br />
count++;<br />
}
|
|
|
|
|
thanks for your answer, it works
|
|
|
|
|
Here is my code to move list items down the list.
<br />
if (!(listView1.SelectedIndices.Count == 0))<br />
if (!(listView1.SelectedIndices.Count > 1))<br />
{<br />
if (listView1.SelectedItems[listView1.SelectedIndices.Count - 1].Index != listView1.Items[listView1.Items.Count - 1].Index)<br />
{<br />
int current = listView1.SelectedItems[0].Index;<br />
ListViewItem lvi = new ListViewItem();<br />
lvi = (ListViewItem)listView1.Items[current];<br />
listView1.Items[current] = (ListViewItem)listView1.Items[current + 1].Clone();<br />
listView1.Items[current + 1] = lvi;<br />
listView1.Items[current + 1].Selected = true;<br />
}<br />
}<br />
If there are more then 4 items in the list it will move down the list no problem but "listView1.Items[current + 1].Selected = true;" will not work, it will select the wrong item after (appears to be listview1.Items[current + 3] thats being selected.
What is causing this and how do i fix it?
|
|
|
|
|
Hi,
Can anybody give an example of Virtual functions in .Net? Eventhough I searched in google, I didn't get any site that explains virtual functions in simple terms. Will be great if you could provide an example or provide an url that explains with example.
Thanks in advance.
Meeram395
|
|
|
|
|
HI consider this situation
using System;
using System.Collections.Generic;
using System.Text;
namespace @virtual
{
class Base
{
public void Display()
{
Console.WriteLine("I am from base");
}
}
class Derived : Base
{
public void Display()
{
Console.WriteLine("I am from derived");
}
}
class Program
{
static void Main(string[] args)
{
Base b = new Derived();
b.Display();
Console.Read();
}
}
}
The result will be I am from Base
If you want to dispaly the derived class method you can use virtual methods
using System;
using System.Collections.Generic;
using System.Text;
namespace @virtual
{
class Base
{
public virtual void Display()
{
Console.WriteLine("I am from base");
}
}
class Derived : Base
{
public override void Display()
{
Console.WriteLine("I am from derived");
}
}
class Program
{
static void Main(string[] args)
{
Base b = new Derived();
b.Display();
Console.Read();
}
}
}
this will give I am from Derived
Its like abstract methods, Try to learn design patterns,in which virtual methods are used
My small attempt...
|
|
|
|
|
// ClassA
class A
{
public void M()
{
Console.WriteLine("A.M() being called");
}
public virtual void N()
{
Console.WriteLine("A.N() being called");
}
}
// Class B
class B : A
{
public new void M()
{
Console.WriteLine("B.M() being called");
}
public override void N()
{
Console.WriteLine("B.N() being called");
}
}
say
A a = new B();
a.M();
a.N();
The results would be
A.M() being called
B.N() being called
|
|
|
|