|
Is its windows forms or asp.net datagrid ?
There are various ways you could do it, can we see what you've got and then take it from there ?
Try not! Do or do not, there is no try. - Master Yoda
|
|
|
|
|
Convert the 32-bit integer (like ff453787) to an int , then call Color.FromArgb(int) to get the color. You can then use Color.ToString . Note that for colors not defined in the KnownColor enumeration, a hex value like you already have will be output:
try
{
int argb = int.Parse("#ff453787$Shirt".Substring(1, 8));
Console.WriteLine(Color.FromArgb(argb));
}
catch
{
} If you want to match these up with colors in your "Colortab" table, then you'll need to perform a separate look-up. I would suggest constructing your SQL query to return these as separate columns to make it easier to bind. You could also in that case use a JOIN or UNION to use the names in "Colortab" instead of the hex values. You can always re-concatenate these on the server or in your client code if you want to.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks
i got. let my try that.
Sreejith S S Nair
|
|
|
|
|
i tried your answer. but i can't see the color and no error. Only i can view the value 0 on the place of color.
Sreejith S S Nair
|
|
|
|
|
I am trying to retrieve a property from the current executing assembly using the following but am getting a TargetException
int MyInt = Convert.ToInt32(Type.GetType(Page.GetType().BaseType.FullName).GetProperty("MyIntProperty").GetValue(null,null));
Anybody know what I'm doing wrong?
Thanks
monkey say, monkey doo
Uncle Monkey
|
|
|
|
|
Wow! You really should split your lines up into distinct pieces - it greatly helps during debugging your application.
You're doing a few things that aren't necessary and would hamper performance, like Type.GetType(Page.GetType().BaseType.FullName) . Instead, you already have your Type using just Page.GetType().BaseType .
Also, when you call GetValue you must pass the instance of the object (presumably Page ) otherwise you would get an exception since you're trying to retrieve the value of a null reference.
Also, if you flatten your instance members, you really don't need to refer to the base Type to get the property where it's declared. Unless BindingFlags.DeclaredOnly is specified, all instance properties - both declared and inheritted - are reflected (not so with statics, unless you specify BindingFlags.FlattenHierarchy ). In ASP.NET, which I assume you're using since you have a Page object - though this could be anything - there is actually a large hierarchy of pages that extend from the Page class, such as your .aspx file : your code-behind page class : Page .
Type t = Page.GetType();
PropertyInfo prop = t.GetProperty("MyIntProperty", BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic);
int MyInt;
if (prop != null) MyInt = (int)prop.GetValue(Page, null);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, worked a treat
monkey say, monkey doo
Uncle Monkey
|
|
|
|
|
Hi there,
I have one question regarding adding code comments (summary, etc.) to namespaces and assemblies.
If I generate the comment web page I get some html pages which contains my comments for classes and members, but not for namespaces and assemblies.
In java (or at least in Eclipse) there is a choice to have package.html documents to be included as document comment for packages (namespaces). Is there any such feature in .Net, C# or Visual Studio .Net (2003)?
If not, are there other tools to create proper reference manuals from code comments in C#.
Thank you!
Michael
|
|
|
|
|
There is no standard tags for commenting a namespace. If you use NDoc[^], we did add the capability to do so however, and it's discussed in the product documentation. NDoc is a very power, extensible, and FREE API documentation generator for .NET and can generate many types of documentation formats, like HTML Help 1, Help 2 (for VS.NET), and several others. You can always add your own documenters as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, for your quick answer. I will take a look into NDoc, this should indeed solve my problems.
Thanks again!
Michael
|
|
|
|
|
i'm a newbie in C#. I have a datagrid and I want that when I doubleclick a row to load a new form with textboxes in which I'll have the data from that specific row. how can I pass the data between the datagrid and the new form textboxes?
Thx in advance and I hope I was clear in my request, because my english really sucks )
|
|
|
|
|
hi,
follow the steps below...
a) Write a class that can hold the inputed data(values from textboxes)
b) Make an object of this class in your calling form
c) handle the double click event of the datagrid.
d) In the delegate instantiate the data entry form and open it as modal dialog
e) while instantiating data entry form pass the object of the data class through the contructor(you need to modify the constructor of the data entry form to accept an object of type : data class)
f) Give the "ok" or "close" button in the data entry form a dialog result... say "OK"
g) On click event of ok button populate the data class with the values.
h) in the calling form check for the dialog result right after you call "ShowDialog()" in the data entry form
i) if the dialog result is OK then populate the datagrid with the values in the class object
rest is upto your guess work... and how u can enhance this...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
|
//Note : before running this code please show some data on datagrid.
//write your code on doubleclick event of your data grid.
//this code is not full. here you will get
//an idea and remaining you have to develop based on your requirement.
//If this is not self explanatory then please let me know that.
//here you will get the point that where you clicked.
Point pt=dataGrid1.PointToClient(Cursor.Position);
//row or coloumn no where you clicked
DataGrid.HitTestInfo hit=dataGrid1.HitTest(pt);
//here i am checking whether i clicked on row header the show the form .use Hittesttype enum to achive your idea
if(hit.Type==DataGrid.HitTestType.RowHeader)
{
Form2 Frm=new Form2();
Frm.ShowDialog();
// you got the idea right.
//use the below line to get data from datagrid or set data to datagrid
dataGrid1[hit.Row,0]="haha";
}
Sreejith S S Nair
|
|
|
|
|
thx a lot, this was very helpful
|
|
|
|
|
hai there,
i have a form with two label control. i need to click on that control. how ? using mouse right. ha ha.
here i need to call the click event programatically without clicking on that control. I won't use any custom event handler here .
Is it possible to control the event triggering through programmatically
Sreejith S S Nair
|
|
|
|
|
Hi,
If you are trying to call the event delegate from any perticular place... say...
you want that when you click on the first label the second lebel controls click event should trigger...
if this is your plan... then you don't need to trigger an event actually... you call the delegate method directly with the necessary parameters... or incase you don't need the parameters send null.
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
if you don't have clear picture of problem and solution please don't reply any queries.
Sreejith S S Nair
|
|
|
|
|
Hold it!
Since your a beginner at this, your problem descriptions will no doubt be vague at times or completely incomprehensible, especially since your English is also not too good. I suggest you cut us some slack...If we can't understand you, we're going to ask questions and make suggestions for further clarification. If you can't provide a clear description of the problem, it's not your place to jump down someone's throat, especially if they are trying to understand and help you...
...the soapbox is now available...
RageInTheMachine9532
|
|
|
|
|
If you're calling this from within a Control , you can call the undocumented protected member InvokeOnClick like so:
InvokeOnClick(label1, EventArgs.Empty); Otherwise, you'll have to P/Invoke SendMessage (see http://pinvoke.net/default.aspx/user32.SendMessage[^]) and send WM_LBUTTONDOWN (0x0201) and WM_LBUTTONUP (0x0202) in sequence using the Handle property of the control for which you want to simulate a click as the first parameter to SendMessage .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for your this mail and your nice suggection. In future also i am expecting the same if i make any mistake.
The main problem is now i have little pressure in my office. So i won't get time to tryout the queries. What normally i will do is, will give little idea that known to me. And if it is wrong i will surly appologies that.
I get into dotnet through book and online material only. So this may happen.
I will try my level beat to avoid this sort of problems.
Sreejith S S Nair
|
|
|
|
|
Hi, I must get a string from a function included into a DLL, imported in a ASP.NET page.
The code:
----
Into a .aspx.cs page:
//def. function included into a DLL
[DllImport("WebUtility.dll", EntryPoint = "getDescr")]
public static extern string getDescr(int id);
//call the function:
string descr=getDescr(123);
---
into the c++ program, the function is definied as:
char* getDescr(int id) {
char* ret=new char[LUNGHEZZA_STRINGA_MEM];
strcpy(ret,oggetto[id].descr);
return (ret);
}
If I throw the application, the server give me the error: System.NullReferenceException: Object reference not set to an instance of an object.
But this error is generated not every time, but random!! some time I can view the string correctly! Why?
Thanks for the help!!!
|
|
|
|
|
First of all, you don't need the EntryPoint property if the entry point is the same as the declared method name.
Second, where is the NullReferenceException getting thrown? It wouldn't be thrown from string descr = getDescr(123); . Perhaps the descr is null and you're trying to call a method on it, but you should always check conditions and not assume anything, such as if an actual reference was returned (value types can never be null unless they're boxed).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
reply 1) there are various funcion into a DLL, so I need an Entry Point
reply 2) into a DLL, descr is NEVER null, I created a function that print out a log file that contain the descr value.
I don't understood because "NullReferenceException" one time get thrown and the next time no!
bye
|
|
|
|
|
Trust me - I know interop in .NET. You don't need to specify the entry point if the method name is the same because the method name is used as the entry point.
I wasn't talking about in your C/C++ DLL - it wouldn't throw a NullReferenceException anyway - that's thrown by the runtime. I was talking about the variable that takes the return value of getDescr called descr . If it's null and you try calling a method on it you will get a NullReferenceException . Assuming that your code "just works" is never a good practice.
Microsoft MVP, Visual C#
My Articles
|
|
|
|