|
you can also create your own editor class.
1. create a new class and implement the openfiledialogeditor.
override the initialize methode (this methode have 1 parameter e.g. the
openfiledialog) now, in the methode you can set your own properties e.g title, filter ....
2. change the editorattribute in the property to your class
[Browsable(true), Description("The filename for the destination.")]
[EditorAttribute(typeof(MyNamespace.MyFileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string FileName
{
get {return _FileName;}
set {_FileName = Path.GetFileName(value);}
}
|
|
|
|
|
Is there anyway of creating a graphics object without using the following methods
1) Graphics g=e.Graphics;
2) Graphics g=this.CreateGraphics;
i an asking this because i want to create a graphics object in my own userdefined function
|
|
|
|
|
What is it that you are trying to do? What is the purpose for using a Graphics object? Answering these questions would give us a better idea of how to help you.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
There are several static functions on the Graphics class. Which one to use depends on what you try to achieve.
Example:
Bitmap b = new Bitmap(100, 100);
using (Graphics g = Graphics.FromImage(b)){
g.FillRectangle(Brushes.Red, 10, 10, 20, 20);
}
|
|
|
|
|
Hi.
I have struct in C++:
struct MY_STRUCT
{
int x;
int y;
char** arrNames; //array of strings
}
I have function GetMyStruct, which gives me pointer to this struct, but
I can't get the array of strings (MY_STRUCT.arrNames).
MY_STRUCT* GetMyStruct();
In C# :
public struct MY_STRUCT
{
public int x;
public int y;
public string[] arrNames; //array of strings
}
public class MyWrapper
{
[DllImport("MyDll.dll")]
private static extern IntPtr GetMyStruct();
public static MY_STRUCT GetMyStructW()
{
IntPtr p = GetMyStruct();
return (MY_STRUCT) Marshal.PtrToStructure(p, typeof(MY_STRUCT));
}
}
BUT MyWrapper.GetMyStructW() doesn't work. Plllease help.
jurot
|
|
|
|
|
Try changing your c# struct to the following:
public struct MY_STRUCT<br />
{<br />
public int x;<br />
public int y;<br />
public System.IntPtr arrNames;<br />
}<br />
<br />
Your calling code looks like this:<br />
<br />
public class MyWrapper<br />
{<br />
[DllImport("MyDll.dll")]<br />
private static extern IntPtr GetMyStruct();<br />
<br />
public static MY_STRUCT GetMyStructW()<br />
{<br />
IntPtr p = GetMyStruct();<br />
IntPtr pArray;<br />
IntPtr pString;<br />
string[] strings;<br />
MY_STRUCT s;<br />
<br />
s = (MY_STRUCT)Marshal.PtrToStructure(p, typeof(MY_STRUCT));<br />
<br />
pArray = s.arrayNames;<br />
<br />
<br />
pString = Marshal.ReadIntPtr(pArray);<br />
<br />
while( pString != null )<br />
{<br />
strings[i] = Marshal.PtrToStringUni(pString);<br />
i++;<br />
pString = Marshal.ReadIntPtr(pArray);<br />
}<br />
<br />
return ( s );<br />
<br />
<br />
}<br />
}
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thanks. Finally it works
jurot
|
|
|
|
|
Hi once more,
I found out, that it works fine only if I have MY_STRUCT.arrNames 1 string!
When I have more than one, all strings in the result array are the same.
I guess the cycle
while( pString != null )
{
strings[i] = Marshal.PtrToStringUni(pString);
i++;
pString = Marshal.ReadIntPtr(pArray);
}
in Marshal.PtrToStringUni(pString) is reading still the same value MY_STRUCT.arrNames[0].
jurot
|
|
|
|
|
Try this:
while( pString != null )
{
int byteCount;
strings[i] = Marshal.PtrToStringUni( pString );
i++;
byteCount = System.Text.Encoding.UnicodeEncoding.GetByteCount(strings[i]));
pString = Marshal.ReadIntPtr( pArray, byteCount );
}
I hope this helps.
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
How do I format a string so that it is displayed in a grid with mixed fonts.,just like that!
Thanx.
-- modified at 9:21 Monday 16th January, 2006
|
|
|
|
|
There is no built-in way for this. You will have to create your own custom DataGridColumnStyle and implement it yourself
|
|
|
|
|
At least I know where to go next! Thanx.
|
|
|
|
|
Hi there,
I need some help of changing extensions of files..
My code so far is:
<br />
string filename = Path.Combine(@"C:\Test.txt", @"C:\Test.txt");<br />
filename = Path.ChangeExtension(filename, "old");<br />
the filename variable does equal C:\Test.old but it never actual changes the extension in windows "explorer"...
i tried so many different ways but always get stuck with this problem..
Please help thanks
Best regards
|
|
|
|
|
The functions you are using are just helper functions for correct string manipulation.
You should use either
File.Move(filename, Path.ChangeExtension(filename, "old"));
or
new FileInfo(filename).MoveTo(Path.ChangeExtension(filename, "old"));
|
|
|
|
|
Thanks Robert,
this is the code i used and it works perfectly
<br />
string filename = lboxFiles.Items[x].ToString();<br />
new FileInfo(filename).MoveTo(Path.ChangeExtension(filename,cmbxRenExt.SelectedItem.ToString()));<br />
One question though,if i use the MoveTo isnt it bit slower than actually just renaming the extension because now it moves over replacing every file?
the reason im asking is because i have to scan and change over 500000 file extensions lol...
Thanks for ur help i really appreciate it...
Regards
GermanD
|
|
|
|
|
Move is intelligent. As long as you remain on the same drive Move is not really moving all bits of a file but is just changing an entry somewhere in the file system. It's like in Explorer. There you can also 'move' files between directories with nearly no time loss.
But 500000 will nevertheless take some time probably.
|
|
|
|
|
U right
Thanks alot Robert i really appreciate the help u give me
Regards
|
|
|
|
|
I have been asked to investigate the possibility of writing a "virtual printer driver", so that we can distribute to our customers to enable them to print-to from any third-party software and allow us to generate an XML file output with text and some "information" about some graphics!
If anyone can direct me towards either some URL's or books etc, that can assist in the development of printer drivers I would be very appeciative of them Any advise on the matter would also be appreciated, especially if you have written printer drivers before.
|
|
|
|
|
I'm fairly sure that it is impossible to write a driver in C# at this point. Check the C++ forum instead.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi,
I want to add a spell checking textbox to a c# project I have, is this possible? I have all the relevant software (WinFX runtime, extensions for VS2005 Express etc.) but there is no way to enable the textbox.IsSpellCheckEnabled property I have read about.
Is it possible to make a custom WinFX control which is a spellchecked textbox, then add that to my project? If so is there any documentation on how to achieve this?
thanks!
|
|
|
|
|
Hey tecchies,
For a project I'm working on that moment, we need to create a new database in Sql Server 2005 (to make use of the native xml datatype). One of the things which seems to be plugged a bit in 2005 is the use of managed code stored procedures.
Has anyone had any experience of writing and using these? Can you advise on their advantages and of any difficulties you may have encoutered? I'm no database expert, but I would have thought that they would lack the 'execution plan' which standard stored procedures provides. In fact, I can't see a great deal of point of this new technology.
Any views/experiences would be welcome.
Thanks
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: I'm no database expert, but I would have thought that they would lack the 'execution plan' which standard stored procedures provides. In fact, I can't see a great deal of point of this new technology.
There are many things you can do with C# that you cannot do in SQL, or is very difficult in SQL.
As Microsoft have said on countless occasions, CLR integration in SQL Server does not mean you can ditch SQL and replace everything with C# code. The CLR integration is for doing stuff that is difficult or impossible to do in SQL directly. It can also be used for creating custom types in SQL Server.
For me, I've not yet tried any of this yet. I'm waiting until I hit something that is obviously crying out for CLR integration to make it run great. However, I've not found it yet.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I have a ListView controls with 10 ListViewItems with checkbox. Now when I list the Items, I need to disable or make read-only the 5th item so that I will not be able to select the that item. How can i do this?
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
HI, I have the same problem. Just wonder if you have got any answer for it?
Thanks
Best Regards
Chibi Maruko S
|
|
|
|
|