|
|
Thanks for that Leppie.
But i dont want to use typeconverters, rather i would like to use custom type editors to solve my problem . wish i can get some piece of sample code which is tested having the required attributes.Because the attribute is not being able to pick up properly which is as follows
[Editor("WindowsFormsPropertyBag1.Form1.ComboBoxListEditor",typeof(System.Drawing.Design.UITypeEditor))]. Do you need more information about the problem??.
Thanks and Regards,
IianforCodeProject
|
|
|
|
|
Good Day People,
I have a DLL. It takes in some parameters, and returns some output. This DLL has to be called form a EXE, which has a GUI Interface.
The portion of code where the DLL returns the solutin is pasted below.
The doubt is; when I call the DLL it returns "n" solutions. I need to take the first solution and show output, while the DLL should be proessing the other solutions.
So I think I should be raising an event, that outputs the first solution. I dot know how to handshake between my EXE and DLL properly. Can you assist?
------------------------------------------------
Code:
------------------------------------------------
forward = true;
while (!myStack.IsEmpty())
{
if (forward)
{
CurrentPtr = -1;
}
else
{
CurrentPtr = (int) myStack.Pop();
CurrentSolution.RemoveAt(myStack.Count);
myArray.RemoveAt(CurrentSolution);
}
CurrentWord = this.Problem.NthWord(myStack.Count);
strExistingWord = myArray.GetStringAt(CurrentWord);
myDict = (Dict) Dicts[myStack.Count];
newPtr = myDict.GetWord(strExistingWord,CurrentPtr, ref strNewWord);
if (newPtr != -1 )
{
CurrentWord.Word= strNewWord;
CurrentSolution.AddWord(CurrentWord);
myStack.Push(newPtr);
myArray.StoreAt(CurrentWord);
forward = true;
if(myStack.Count == this.ProblemSize)
{
Solution newSolution = CurrentSolution.Clone();
this.alSolutions.Add(newSolution);
//return;
// newSolution.writeSolution();
// System.Console.ReadLine();
forward = false;
}
}
else
{
forward = false;
// show the combinations
//this.show(myStack.ToArray());
//System.Console.Write("{0} ", ShowInPC(myStack.ToArray(),Dicts));
}
}
return;
Md. Sathik
|
|
|
|
|
Good Day People,
I have a DLL. It takes in some parameters, and returns some output. This DLL has to be called form a EXE, which has a GUI Interface.
The portion of code where the DLL returns the solutin is pasted below.
The doubt is; when I call the DLL it returns "n" solutions. I need to take the first solution and show output, while the DLL should be proessing the other solutions.
So I think I should be raising an event, that outputs the first solution. I dot know how to handshake between my EXE and DLL properly. Can you assist?
------------------------------------------------
Code:
------------------------------------------------
forward = true;
while (!myStack.IsEmpty())
{
if (forward)
{
CurrentPtr = -1;
}
else
{
CurrentPtr = (int) myStack.Pop();
CurrentSolution.RemoveAt(myStack.Count);
myArray.RemoveAt(CurrentSolution);
}
CurrentWord = this.Problem.NthWord(myStack.Count);
strExistingWord = myArray.GetStringAt(CurrentWord);
myDict = (Dict) Dicts[myStack.Count];
newPtr = myDict.GetWord(strExistingWord,CurrentPtr, ref strNewWord);
if (newPtr != -1 )
{
CurrentWord.Word= strNewWord;
CurrentSolution.AddWord(CurrentWord);
myStack.Push(newPtr);
myArray.StoreAt(CurrentWord);
forward = true;
if(myStack.Count == this.ProblemSize)
{
Solution newSolution = CurrentSolution.Clone();
this.alSolutions.Add(newSolution);
//return;
// newSolution.writeSolution();
// System.Console.ReadLine();
forward = false;
}
}
else
{
forward = false;
// show the combinations
//this.show(myStack.ToArray());
//System.Console.Write("{0} ", ShowInPC(myStack.ToArray(),Dicts));
}
}
return;
|
|
|
|
|
HI
I'm beginner in C# Builder, And need to know how I can read from textbox or richtextbox.
And how I should draw Function like (y=sin(x)), IN VB usually drawing is in picturebox,
but I'm not very familiar with C# structure. I need the source code, cause I Havn't enough
time now to learn it, I should learn it later. if you can guide me.
thank you.
TA RedStar
|
|
|
|
|
|
Hello again! I'm on the last stretch of my 1st ever c# program and I really need help in solving this last, yet possibly hardest problem i've encountered yet.
Well I have this program that saves the output of my query in a datagrid into text file. I've accomplished half of it meaning I can save it at a target location but:
1. Why can I only save it in specific folders like c:\Temp? I'm hoping I could save it on the desktop.
2. Why doesn't a command prompt appear when I click the save button? It save directly and doesn't even inform the user that it has been saved although it already is.
3. How do I solve this problem?
I've tried searching the net for possible solutions but failed. Here's my code:
private void btnSave_Click(object sender, System.EventArgs e)
dtMain = objBM.fMain(DropDownList1.SelectedItem.Value,DropDownList2.SelectedItem.Text);
StreamWriter sr = File.CreateText("c://Temp//SSS.txt");
string strout;
if (dtMain.Rows.Count > 0)
{
for (int intptr = 0; intptr <= dtMain.Rows.Count - 1; intptr++)
{
strout = " ";
for (int intptr2 = 0; intptr2 <= dtMain.Columns.Count - 1; intptr2++)
{
strout += dtMain.Rows[intptr].ItemArray[intptr2] + " ";
}
sr.WriteLine(strout);
}
}
sr.Close();
}
Any and all suggestions, reactions and informations would be greatly appreciated. Thanx for all your helps!
thanx
|
|
|
|
|
1) you can save it anywhere you choose to - try searching for Environment.SpecialFolders.Desktop to find out more about getting the desktop directory. At the moment you are creating a file in the specific path with this line - StreamWriter sr = File.CreateText("c://Temp//SSS.txt");
2)If you want a dialog to appear try looking into the saveFileDialog control (it should be on the toolBox by default)
Then you could use the FileOk event of this control to save the file to wherever the user has selected.
|
|
|
|
|
Are there some compiler or .NET framework predefined macros, such as the _ATL_VER, _MFC_VER, _MSC_VER for the C#?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Macros suck, I regret that C# supports them at all. Yes, I believe there is DEBUG for debug versions, and TRACE also. They are shown in the project properties for a debug build, you can add more.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks.
I do not see what is regretable about macro support in C#. You simply do not have to use what you do not have a use for. I needed to create an interface library for both .NET 1.1 and 2.x, and do not want to do this again. So, I want to have something like
#if version 1.x
IPositionList Positions
#else // version 2.x
List<IPosition> Positions
#endif
{
get;
}
where is a IPositionList is a strongly-typed list of IPosition for use in
the version 1.x.
I do not know if anything else can do this better than macros. I will defined my own macros - just trying to find out if "standard macros" exist
for this kind of stuff.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
I do not see what is regretable about macro support in C#.
I agree, I have been thinking of using the C/C++ preprocesser on C# but havent got that far :p As CG said, DEBUG TRACE are common defines, but they are ONLY used inside the project your are compiling and has no effect on dependant assemblies, like u would have in C/C++.
So your best bet is to use something like VERSION_1 and VERSION_2. Remember you can use this to your advantage as follows (the compiler might have some issues IIRC):
#define VERSION_1
using AnyPositionList =
#if VERSION_1
IPositionList
#else
List<IPosition>
#endif
;
Now in your code:
AnyPositionList Positions
{
get ..... ;
}
HTH
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
Thanks for the information.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
I do not see what is regretable about macro support in C#.
I agree with Stroustrup on macros. I think they suck. Having said that, I can't imagine any way of supporting a debug build without them, so I'm sure I'll use them at some point.
Paul Selormey wrote:
I do not know if anything else can do this better than macros.
Sure. The version 1.x code will just work in both cases though.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all...
Can there be an optional or default parameter in C#? If yes what would be the syntax of the same?
|
|
|
|
|
You can define a params collection, otherwise you need to write several methods like this":
void DoSomething(int i, int j, in k)
{
}
void DoSomething(int i, int j)
{
DoSomething(i, j, 5);
}
void DoSomething(int i)
{
DoSomething(i, 2, 5);
}
Obviously, this is less than ideal.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ya...one option is of method overloading, but when we have more number of params to be kept as optional one has to type a lot. Is there any other work around as in VB.NET we have an optional keyword which specifies the parameter is optional and with the specified default value.
|
|
|
|
|
To reiterate: no.
I recently found out that VB.NET supports optional parameters and C# does not. Until then, I thought that VB.NET was always the loser, I guess that's not the case.
Having said that, I think that an interface where a method takes 20 parameters and 10 are optional is just sloppy coding anyhow.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
C# vs VB is all a matter of style.
If you look closely at the features of both languages, you'll see that VB offers about as many features that C# doesn't have that C# offers that VB doesn't have.
C#:
- allows unsafe code (I've yet to meet anyone who does this in C# though)
- has the 'as' operator (but VB has it in 2005 - 'TryCast')
- allows assignments within expressions (e.g., if ((x = y.Value) == 2))
- operator overloading
VB:
- has optional parameters
- allows types within interfaces (although I've never wished I had this in C#)
- has a very flexible Select construct (much, much more flexible than 'switch')
- has the "When" filter for catch block headers (ok - I'm really stretching now...)
And this one is a doubtful benefit of VB: it gives you half a dozen ways to do a lot of things - some regard it as a benefit, while others hate it since it makes it harder to produce standard code in teams.
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
|
|
|
|
|
Hi David. Have I bought your program ? Whichever VB->C# converter I bought, it truly rocked !!!
David Anton wrote:
allows unsafe code (I've yet to meet anyone who does this in C# though)
You're talking to one right now. Vital for image processing, although I'm told there's a non-unsafe way, I am yet to see the code to know what it is ( setpixel does NOT count ).
David Anton wrote:
has the 'as' operator (but VB has it in 2005 - 'TryCast')
Trouble is, most VB.NET users prefer to use the older casting operators, the ones that were in VB6. The problem with VB.NET is not lack of features, it's terrible hacks that have been maintained for legacy support ( and which Microsoft initally wanted to remove ).
David Anton wrote:
VB.NET : has optional parameters
Yeah, these would be nice, although I read a rationale against them online which made sense. All about performance.
David Anton wrote:
And this one is a doubtful benefit of VB: it gives you half a dozen ways to do a lot of things - some regard it as a benefit, while others hate it since it makes it harder to produce standard code in teams.
A problem that VB.NET only intensifies. It's my experience, from working on projects that are already in progress, that on average, VB.NET users know a hell of a lot less about good design and coding standards than C# users. It's also my experience that they don't use the new VB.NET features, because they are coding as if it was still VB6. I doubt many of them even know what it is they are asking the compiler to do.
Whichever converter I bought, it won me a whole lot of work, because I was able to convert a huge VB.NET program to C#, and I have worked on it ever since. I agree, style is an issue, I hate VB.NET syntax, but there's more to it than that, and the core issue is the sort of people who are using each language, on average. I'm sure there are good VB.NET coders and bad C# coders in the world, but overall, the trend is in the other direction.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have been working with xml files for a while; however, now I have to work with a xml file that has several relations that are not hierarchical which makes it a bit harder to manipulate with XmlDocument so I figured I could use datasets because a dataset automatically creates all the necessary tables. So to test it out I assign a table to the datasource of a datagrid.
My problem is that when new rows are added to the datagrid, and I call my dataset's WriteXml method, the new rows are added at the root level and my file looses its original tree hierarchy.
For example, if my original xml file is as follows:
<?xml version="1.0" standalone="yes"?>
<root xmlns="http://tempuri.org/Database.xsd">
<Database>
<Positions>
<Position PositionCode="1" PositionName="Operations Supervisor" Salary="0" />
</Positions>
</Database>
</root>
Then I set the DataSource to of a datagrid to "Position" table and after adding a couple of rows, the saved file looks like:
<?xml version="1.0" standalone="yes"?>
<root xmlns="http://tempuri.org/Database.xsd">
<Database>
<Positions>
<Position PositionCode="1" PositionName="Operations Supervisor" Salary="0" />
</Positions>
</Database>
<Position PositionCode="2" PositionName="Secretary" Salary="0"/>
<Position PositionCode="3" PositionName="LazyGuy" Salary="0"/>
</root>
Note that the new rows were added in "/root" instead of in "root/Database/positions"
Please let me know if there is a way to preserve the xml tree hierarchy when using datasets.
Many thanks in advance.
|
|
|
|
|
Hello,
i'm sending a message from a C++ program to a C# program using following code:
CString strParam = "TEST";
pWnd->SendMessage (WM_USER + 200, NULL, (LPARAM)(LPCSTR)strParam);
In C# i have following code:
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_USER + 200)
{
string strTest = (string) m.GetLParam (typeof(string));
}
base.WndProc (ref m);
}
I want to get the string in the C# program using the m.GetLParam method. However, that does not work. Do you have any ideas?
|
|
|
|
|
I don't know if it's the case here (it's been years since I programmed in Win32) but some messages parameters are not marshalled across process boundaries.
When you use WM_GETTEXT to get another process's window caption, Windows sees that you are passing a pointer, and copies the memory pointed to by the address in lParam to the other process, sends the message, and then brings the memory back to your process.
But if it's a app-specific message (above WM_USER ) Windows has no way of knowing that the lParam is a pointer to some memory located somewhere else in your process address space, instead of a scalar value.
In this case, you would need to use ReadProcessMemory /WriteProcessMemory (are they called like that?).
You could also try the WM_COPYDATA message. As far as I understand, this message was designed specifically for this kind of uses (interprocess communication) and the data gets marshalled automatically.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
hii all,
what is the Cache-Control and what is the diffrence between private and public cache?
thanks alot for your time.
marcoryos
|
|
|
|
|