|
Hi
I am writing a form application to just display the movie names. I have a second class called Movie where I have hard coded two movies to dispplay in the Form class. Both Form amd Movies class are in same directlry and have same namespace. But still I am getting msg
"The type or namespacen name Movies does not exist in the namespace MoviesIsaw (are you missing an assembly reference?))
Can you pls tell me what Iam doing wrong.
|
|
|
|
|
Is the class called Movie or Movies ?
I would create both so each movie is an individual object and all movies can be added to a collection called Movies
public class Movie
{
private string name;
public Movie(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
}
}
public class Movies : List<Movie>
{
}
|
|
|
|
|
Thansk muh for swift response. This is what I have
MoviesIsaw.Form1.cs
namespace MoviesIsaw
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string mn;
mn = MoviesIsaw.Movies.MovieArray[0];
testBox1.Text = mn;
}
}
}
Movies.cs
using System;
using MoviesIsaw;
namespace MoviesIsaw
{
public class Movies
{
str [] MovieArray = {"Benher","TOP GUN"};
}
}
|
|
|
|
|
|
Hooray, Tx much it works now. got the concept as well.
Two mistakes I did
did not create the object - Still thinking in my old procedural way. (11 years of it does not die that fast..)..)
Did not include the cs file part of the project
Thanks for the help and am happy about this great site..
cheers, Ravi
|
|
|
|
|
Hello,
It looks like you made a mistake somewhere in the typing and you know how ,use the word "Movies" instead of "Movie" as your seckond class is called.
It would be good to see the piece of code that is related to this error.
All the best,
Peric Zeljko
periczeljkosmederevo@yahoo.com
|
|
|
|
|
Hi,
I am facing some issue to set the IPv6 address programatically to the adapter. For IPv4 Win32_NetworkAdapterConfiguration WMI class was used to set the IP addresss.
Could some one help to share the API or any other way to set the IPv6 address.
Thanks
|
|
|
|
|
Hi,
I have a Stored Procedure in SQL server which returns multiple tables...
using IMultipleResults in Linq to SQl is there a way to fetch only one table from the result ....Please help me regarding the same....
|
|
|
|
|
Can't you cut down the stored proc to give just the results you want? Otherwise you're making the DB do more work than necessary, bad for performance and scalability.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for ur solution....but please let me know whether is it possible to fetch only the desired single result from the SP"s result set...
|
|
|
|
|
cant you just use .GetResult<T> where T is the type of result you want?
|
|
|
|
|
ya thats true but that is not giving me the desired result, we need to fetch other results also prior to this(need to follow the sequence of result sets returned from the sp)..if my result is last one in the SP.....
|
|
|
|
|
sounds like you have to seperate your mega SP into smaller SPs to me then, still cant see why this is a prob without some code
|
|
|
|
|
actually i cannot change my sp ,bcos this is used in many other places of code they fetch
particular resultset which i require....
so please let me knoiw is there a way to fetch only the resultset i need from sp using Imultiplerersults.....
As this is achievable in classic ado.net using tablemappings where we can fetch the desired resultset from SP.
please let me know how this can be achieved in Linq to SQL....
|
|
|
|
|
Hi
I have trouble understanding the code that is on this page
http://www.sanity-free.org/13/numeric_text_box_number_only_text_box_control_in_csharp.html.
In PreProcessMessage I don't understand what the inparameter Message msg property WParam holds or Msg holds. When to use them and for what? I have also heard about the property LParam and HWnd, when should I use them. In WndProc we have
the code m.Result = (IntPtr)0. What holds the inparameter Message m's property Result and what is IntPtr? I have seen codes like
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_GETTEXT:
string s = ModifyOriginalText(this.Text);
int charsToCopy = Math.Min(m.WParam.ToInt32(),s.Length);
m.LParam = Marshal.StringToHGlobalAuto(s.Substring(0,
charsToCopy));
m.Result = new IntPtr(charsToCopy);
return;
}
base.WndProc(ref m);
}
Here they are using the property LParam and here they make a new IntPtr with another amount on int.
I need an accurate explanation when to use Msg, LParam, WParam, Result and for what.
And when we are calling
base.WndProc (ref m);
we want something to happen or what? I mean in the NumericBox example, when it finds not a number it just returns, but why does it have to add (IntPtr)0 to m.Result before. Could they instead have written new IntPtr(0)?
What does the amount to IntPtr tell us?
I know there are many questions, but I so much want to learn this and understand it thoroughly.
Hope you can help me and explain accurate.
Many thanks
Fia
|
|
|
|
|
The author is using the this to override the default Windows message handling process which is what drives a Windows program. In this case he checks to see if the message is WM_GETTEXT and if so returns his modified text to the calling process. This is not generally required in .NET applications but if you are really interested you can take a look here[^] on MSDN.
|
|
|
|
|
Hi
Thanks for the answer. But it doesn't tell me what the Message's properties Msg, LParam, WParam and Result are for. When to use them and what to do with them. And the question what to assign to m.Result, how do I know what to assign? I have seen so many examples when I have googled, but no explanation. I have seen m.Result = new IntPtr(charsToCopy)and m.Result= (IntPtr)0 or new IntPtr(0), but how do I know what integer to assign m.Result what does it differ.
Many thanks
Fia
|
|
|
|
|
The values of WPARAM , LPARAM and the return are all dependent on the message being processed. For example here[^] are the details for the WM_GETTEXT message.
|
|
|
|
|
Hi
Thanks again for your answers, but I have till trouble to understand to use m.Result=IntPtr(0) or what to put in IntPtr.
I have two examples I have googled:
In this example it stops users to paste anything to a textbox.
protected override void WndProc(ref Message m)
{
if (m.Msg != WM_PASTE )
{
base.WndProc(ref m);
}
}
In this example users can just paste in numbers in a textbox.
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_PASTE )
{
IDataObject obj = Clipboard.GetDataObject();
string input = (string)obj.GetData(typeof(string));
foreach (char c in input)
{
if (!char.IsDigit(c))
{
m.Result = (IntPtr)0;
return;
}
}
}
base.WndProc(ref m);
}
Why do we have to assign to m.Result the InPtr 0? What is IntPtr and how do I know which int (amount) I should return?
Many thanks
Fia
|
|
|
|
|
As I explained in my previous answer you need to look at the documentation for each message to know what values are represented by the WPARAM and LPARAM input parameters, and what values may be returned if you process the message. For example the documentation for WM_PASTE is here[^]. You also need to read about the default WndProc() method in .NET here[^].
The use of IntPtr in C# is merely a type that corresponds to the 32 bit DWORD in C++, which is the normal return value from these functions.
|
|
|
|
|
If your goal here is to understand P/Invoke and 'WndProc,' and the use of parameters to P/Invokes ... then great, but, if your goal is to make progress in .NET and WinForms or WPF, then there are other techniques you can use to create an input field that only accepts numeric input that do not require getting 'outside the .NET box.'
Check out 'MaskedTextBox' and 'NumericUpDown' in WinForms, for example.
best, Bill
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
|
|
|
|
|
Hi,
I work with WPF, and I have got a problem with binding a listbox.
The question is as follows.
I have a left list box of ten list box items. On the right hand I have a border where I can exchange between 10 User Controls.
So, I have a 10 listbox items for ten usercontrols. The problem is how to bind these 10 listitems and make them as a menu, so when I click on one of them I get the right User Control on the right side..
If ther is any solution, send please!
|
|
|
|
|
Article that may help[^]
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Bind the ListView's SelectedIndex property to something in the view model. Then bind some property of the border which controls which user control is visible to SelectedIndex, or if there's no property that you can bind which does the job, bind the Visible properties of the user controls to SelectedIndex with a binding converter int->bool which checks to see if it's the right one.
|
|
|
|
|
Help. I've spent way too much time on this. I've scoured the web for ways to set the focus on a cell in my grid and I'm using:
dataGridView1.CurrentCell = dataGridView1[e.RowIndex, e.ColumnIndex]; and it doesn't seem to work. I've found (and tried) more cumbersome ways to do it but I always prefer the simple approach. Could it have something to do with the fact that I call the function from the OnCellValidated method after I've tabbed out of the cell with bad data? Any illumination would be appreciated. thank you.
|
|
|
|