|
err... Set the DisplayMember property on the ListBox?
Set it to a string = to the name of the field you want to display.
Bill
|
|
|
|
|
Also set the ValueMember otherwise the values will be full of the same.
You should also set ddlCity.DataMember to the table name (probably "Table") in the DataSet , or set ddlCity.DataSource = ds.Tables[0]; (if ds != null - never forget error checking!).
Finally, this really belongs in the ASP.NET forum. Since you're calling DataBind - which isn't needed and doesn't even exist in Windows Forms - this is obviously an ASP.NET-related question.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am using the decision tree created by roosvelt and I want to know how to make the target nodew accepts string.Soif any one knowshowto contact roosveltorknows about the decision tree mining algorithm can help me
|
|
|
|
|
If you ask this bloody question one more time, I will personally make sure they ban you off this site. Use Google groups! (and use spaces)
|
|
|
|
|
hai,
i have three methods. one to one interrelated.
Method A Calls Method B and Method B Calls Method C.
my aim is if method C raises any exception i need to catch on method B. And this exception is showed to user on method A.
note: Exception Reporting.
What's your idea ? please help me out.
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
I am guessing Method B does some exception handling, which is why it is being caught there and not in Method A.
public void MethodA()
{
string errorMessage = MethodB();
if (errorMessage != "")
{
}
}
public string MethodB()
{
try
{
MethodC();
}
catch(Exception ex)
{
return ex.Message
}
return "";
}
public void MethodC()
{
throw(new ApplicationException("Something went wrong"));
}
This is one way of doing it. But, as you've not expressed fully what you are trying to do, it may not fit with the design of your application.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
PropertyGrid control always shows a ToolTip when mouse pointer is placed on a property with a large value that is not fully visible in the field. Is there a way to display limited text in tooltip or turn this behavior off?
How to tell PropertyGrid not to show any ToolTip at all?
Thanks for your help
|
|
|
|
|
It is just wierd, I have something like:
ArrayList al1 = .... //filled with some data
combobox1.DataSource = al1;
it is all OK.
BUT, later I have to change the contents of the combobox, so:
ArrayList al2 = .... //filled with something else
combobox1.DataSource = al2;
here cames up with a null DataSource (al2 is correct and no errors are shown).
I also tried to get the ArrauList back:
ArrayList al = (ArrayList)combobox1.DataSource;
al.Add("...");
.....
but nothing changed.
What could be wrong ? I would prefer the first approach.
|
|
|
|
|
varadii wrote:
What could be wrong ?
I've not double checked this, so this may not be right....
When you assign something to the ComboBox.DataSource the ComboBox knows that the source of the data is different and will update its contents accordingly. However if you just add an element to the array the ComboBox knows nothing of this and won't update. So, you have to tell the ComboBox that the array has changed. (Possibly by just assigning the Array back to the datasource)
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
hai,
give me detailed description or usefull link which will help me to update more than one table.
expecting advanced level.excuse basic level
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
You can ask a little nicer.
Selecting multiple tables from a database and filling a DataSet with multiple DataTable s is easy (using a table mapping). Updating in the same way is not. The common approach is to use separate SqlDataAdapter s for each table, taking the necessary order (derived from the DataRelation s, or just hard-code it at design-time if you know it up front) into account.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!
I need to use GPC library in a C# project.
GPC library is written in pure C and is available on http://www.cs.man.ac.uk/aig/staff/alan/software/
So what I did is I worte a Win32 .dll with exports of the library functions:
extern "C"
{
__declspec(dllexport) void gpc_add_contour(gpc_polygon *polygon, gpc_vertex_list *contour, int hole);
__declspec(dllexport) void gpc_polygon_clip(gpc_op set_operation, gpc_polygon *subject_polygon, gpc_polygon *clip_polygon, gpc_polygon *result_polygon);
....etc...
}
So I was thinking...ok...now I have the .dll and now I can use C# attribute DllImport to import functions from .dll.
But as you can see there are structures that pass as pointers to the functions. I don't know how to marshal it/make it usable in C#.
This is my current progress in implementing the port of GPC to C# (I don't know when to use IntPtr or something else):
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace nsGPC
{
public class GPC
{
public enum gpc_op
{
GPC_DIFF,
GPC_INT,
GPC_XOR,
GPC_UNION
}
[StructLayout(LayoutKind.Sequential)]
public class gpc_vertex
{
public double x;
public double y;
}
[StructLayout(LayoutKind.Sequential)]
public class gpc_vertex_list
{
public int num_vertices;
public IntPtr vertex; //pointer to gpc_vertex
}
[StructLayout(LayoutKind.Sequential)]
public class gpc_polygon
{
public int num_contours;
public IntPtr hole; //pointer to int
public IntPtr contour; //pointer to gpc_vertex_list
}
[StructLayout(LayoutKind.Sequential)]
public class gpc_tristrip
{
public int num_strips;
public IntPtr strip; //pointer to gpc_vertex_list
}
[DllImport("GPC.NET.dll", CharSet=CharSet.Ansi)]
public static extern void gpc_add_contour(ref gpc_polygon polygon, ref gpc_vertex_list contour, int hole);
[DllImport("GPC.NET.dll", CharSet=CharSet.Ansi)]
public static extern void gpc_polygon_clip(gpc_op set_operation, ref gpc_polygon subject_polygon, ref gpc_polygon clip_polygon, ref gpc_polygon result_polygon);
[DllImport("GPC.NET.dll", CharSet=CharSet.Ansi)]
public static extern void gpc_free_polygon(ref gpc_polygon polygon);
}
}
Well, anyways...Is anyone here with enough knowledge of porting this library to C#?
MP.
|
|
|
|
|
Since it's a C library, I imagine it has lots of functions. I believe that it would be better write a managed C++ class that calls the C library natively, otherwise you'll lose lots of time writing interop code that MC++ can create automatically for you (it's called IJW). After this, you just add a reference from C# and call it as any managed class.
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|
|
Yeah, but I have to agree with Daniel on this one. P/Invoke is great when you have to call a few exported functions, but many times you run into a lot of problems, especially with lots of exports.
Say one of these exported functions uses nested structs. The marshellers used by the CLR does not support nested structs (and the .NET Compact Framework doesn't even support marshalling a struct at all). All this is easy to accomplish using a mixed-mode MC++ wrapper, exposing classes as a managed class (using the __gc extension, at least until .NET 2.0 is released) and using the native APIs from the native library you're trying to wrap.
I do a lot of interop (both COM and P/Invoke) for fun and I typically choose this route when I need to use a lot of exported functions or more complex functions with nested structs and the like. For an example, see my article, Using XML Digital Signatures for Application Licensing[^] where I use a MC++ assembly that uses a lot of the LSA APIs and exposes that as a managed class I can use with any other ".NET language".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Cool.
Well, I forgot to mention, that this is my first .net project, so I'm kinda lost.
But, I managed to do a wrapper in MC++ and it's working great.
I needed to export only 2 C functions to .net and not so many as you two tought.
Anyways, I'm going to do it for all cca. 10 functions and publish it on the web as .NET port of GPC.
Thanks to both of you for directing me at the right way to solve the problem.
MP.
|
|
|
|
|
Hello,
I've searched IRC for a good C# channel but most of them I don't even get an answer, and believe me, I've waited for it. I can ask a question then leave and come back after a hour and still no answer.
Does Codeproject have an own irc channel?
I think it's a great way of discussing articles here on codeproject or helping each other.
Maybe we should start one if there is none?
Mybae we should not? =)
Anyway, have a good day! =)
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Martin Lundberg wrote:
I think it's a great way of discussing articles here on codeproject or helping each other.
Yeah, not like these forums or the message boards at the bottom of every article, huh?
No, CP does not have it's own IRC channel. That's what the forums are for.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello agagin!
Well yea they are great but it's still not the same thing. It's not real time discussions. The discussions are often slow and sometimes even forgotten.
But I see you didn't like what I said and maybe you are right, a IRC channel would maybe just make the activity of the site to slow down, and thats not a good thing.
but still, If you need help IRC is very good (if they would ever answer =P)
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
If you opt to receive notification messages when you're replied to, they aren't lost. And unlike IRC, all threads are archived and accessible for several years here on CodeProject. If you need real-time communicae, then it means you're not planning ahead researching your project before you start. If you need answers immediately, you didn't plan ahead.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Bah! =P
It's still think it's nice to talk to a person in real time, discussing program related things =)
I'm not saying anything is bad here, I love this site =)
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
|
Word?
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
|
Hi,
I'm have problem with api functions in C#.I want to call API function to retreive listview information such as itemtext, item position... I use function SendMessage to get it but it doesn't work.
//API function :
//#define TreeView_GetItem(hwnd, pitem) \
// (BOOL)SNDMSG((hwnd), TVM_GETITEM, 0, (LPARAM)(TV_ITEM *)(pitem))
and my code in C# is :
public const int LVM_GETITEM =(LVM_FIRST + 75);//unicode
[DllImport("user32", CharSet = CharSet.Auto)]
public extern static int SendMessage(
IntPtr hWnd,
int wMsg,
long wParam,
ref LVITEM lParam);
//with LVITEM is the struct of ITEM in ListView :
unsafe struct LVITEM
{
public uint mask;
public int iItem;
public int iSubItem;
public uint state;
public uint stateMask;
public string pszText;
public int cchTextMax;
public int iImage;
public long lParam;
//public int iIndent;
public int iGroupId;
public uint cColumns; // tile view columns
public uint* puColumns;
} ;
Please show me anything wrong in my struct LVITEM ???
Thank you.
NTHEVU
|
|
|
|
|
Why are you even P/Invoking anything? What you want is already possible using the ListView class and the ListViewItem class. The ListViewItem.Text property gets the text of the ListViewItem , which you can get by enumerating through the ListView.Items or using ListView.SelectedItems or something similar. If you want a particular item's region, then you can use ListView.GetItemRect , which can retrieve information about several parts of a ListViewItem .
Besides, you don't need an unsafe context and your SendMessage declaration is wrong. The wParam should be an IntPtr since it will be 32 bits on a 32-bit OS and 64 bits on a 64-bit OS (which is dependent on the processor). The last member of your struct should also be just an IntPtr .
Seriously, though, don't waste your time doing this. Everything you're trying to do according to your post is easy using what's provided in the .NET FCL (namely, the System.Windows.Forms.dll assembly).
Microsoft MVP, Visual C#
My Articles
|
|
|
|