|
Hi, how do u change the color of the row in datagrid according to their sort.
(sorted by Proj)
Proj Activity
yesh hihi <== this row will be red
yesh byebye <== this row will be red
yesh hoho <== this row will be red
lolo hihi <== this row will be white
lala byebye <== this row will be red
lala byebye <== this row will be red
(sorted by Activity)
Proj Activity
yesh hihi <== this row will be red
hihi hihi <== this row will be red
lolo hihi <== this row will be red
lala byebye <== this row will be white
lolo lalala <== this row will be red
yesh lalala <== this row will be red
this is a sample where there is more columns, rows and values.
Thank you.
|
|
|
|
|
I’m a bit of a nubie and looking for some advice, the code bellow works but looks like a bit of a hack. I know it's a 'WebMethod' its general enough. My concerns lie with the 'Populate product' section toward the bottom.
[WebMethod]<br />
public Product GetProductById(int Id)<br />
{<br />
#region oleDbQueery<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
OleDbCommand myCommand = new OleDbCommand("ProductByIdQueery", oleDbConnection1);<br />
myCommand.CommandType = CommandType.StoredProcedure;<br />
OleDbParameter parameterid = new OleDbParameter("Id",OleDbType.Integer);<br />
parameterid.Value = Id;<br />
myCommand.Parameters.Add(parameterid);<br />
myAdapter.SelectCommand = oleDbSelectCommand1;<br />
myAdapter.SelectCommand = myCommand;<br />
#endregion<br />
DataSet ds = new DataSet();<br />
oleDbConnection1.Open();<br />
myAdapter.Fill(ds);<br />
oleDbConnection1.Close();<br />
Product myProduct = new Product();<br />
myProduct.Id = Int32.Parse(ds.Tables[0].Rows[0]["Id"].ToString());<br />
myProduct.Category = Int32.Parse(ds.Tables[0].Rows[0]["Category"].ToString());<br />
myProduct.ShortTitle = ds.Tables[0].Rows[0]["ShortTitle"].ToString();<br />
myProduct.FullTitle = ds.Tables[0].Rows[0]["FullTitle"].ToString();<br />
myProduct.Price = double.Parse(ds.Tables[0].Rows[0]["Price"].ToString());<br />
myProduct.CurrentQuantity = Int32.Parse(ds.Tables[0].Rows[0]["CurrentQuantity"].ToString());<br />
return myProduct;<br />
}
Sorry for the long snippit. My passed in 'Id' would refer to a unique db key so the dataSet 'should' only ever contain one row.
Do I have to go via a dataSet to populate myProduct object?
All comments greatly welcomed.
tia
|
|
|
|
|
You can use a DataTable instead of a DataSet.
The DataAdapter.Fill() method works with a DataTable object.
Free your mind...
|
|
|
|
|
Try a DataReader.
Thank You
Bo Hunter
|
|
|
|
|
|
I'm writing a control program that will require a lot of screen real estate to interact with the user. One thought I had on how to do this was to use a dual output display adapter and two monitors. I would then create forms that would present specific information on each monitor. My question is how to control which of the two monitors the form is drawn on?
Jeff
|
|
|
|
|
I would recommend looking into documentation for the following keywords:
GetSystemMetrics();
SM_CMONITORS;
SM_XVIRTUALSCREEN;
SM_YVIRTUALSCREEN;
SM_CXVIRTUALSCREEN
SM_CYVIRTUALSCREEN
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Or, since this is the C# forum, see the System.Windows.Forms.SystemInformation class, which includes several properties that wrap such information in a managed class.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Seeing that the others are throwing u off track, have a look at System.Windows.Forms.Screen
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hello all,
I have to set certain values in a datacell based on its orginial value. So 0 stands for Ended, and 1 stands for in progress. For whatever the reason, Im having a difficult time changing the text of a cell in my datagrid. Im sure im doing something stupid, whats wrong with this picture?
DataGridCell oCell;
for(int k = 0; k <= gridEvent.VisibleRowCount; k++)
{
oCell = new DataGridCell(k, 4);
if(gridEvent[oCell].ToString() == "1")
{
gridEvent[oCell] = "In Progress";
}
else
{
gridEvent[oCell] = "Ended";
}
}
}
It throws an error that no set method is provided for the cell object. Am I missing something?
Thanks,
Ryan
|
|
|
|
|
Sorry, I just realized that the datagrid's first element is 1 not zero, where in lies my problem.
Thanks,
Ryan
|
|
|
|
|
OK, not zero, but i figured it out.
Thanks anyways,
Ryan
One of those days.
|
|
|
|
|
We are developing a C# application using .Net AsyncCallback delegates. The application currently executes, as expected,
using these asynchronous methods. Once this application is converted to a COM+ component (i.e. a .NET serviced component)
the program ceases to execute properly and 'hangs' without asynchronously executing the callback delegates.Any help with .Net asynchronous programming under COM+ would be grealty appreciated. Thanks. Rick
Rick
|
|
|
|
|
|
I am handling the double click event on a form (not a control) and I want to know the location of the double click. How? It was easy for a mouse up/down/hover/etc, it was part of the MouseEventArgs. That info is unavailable for the DoubleClick Event. Why? aaaaarrrrrggggg!
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Try using the static System.Windows.Forms.Form.MousePosition .
Andreas Philipson
|
|
|
|
|
Thanks, I had already tried that and didn't get the results I was looking for...then it dawned on me to call PointToClient before I used it. Works fine, now.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
can anyone tell me what kind of help C# or .NET Framework provides to find all/any I/O device(s) installed in the system?
|
|
|
|
|
None. .NET (btw, C# is a language that only targets .NET - nothing special in and of itself) is a higher-level platform. C# and a few other languages that target the CLR do let you use lower-level programming with pointers in an unsafe context, but P/Invoking (calling Win32 native functions) what you need to accomplish what you want, and creating all the structs and what not, would be very time-consuming. Using C# (or the .NET Framework in general) would not be the way to go.
If you need this information in a .NET application, consider putting such functionality in a Win32 DLL and P/Invoking it, or - perhaps better - create a COM object that does this and get that information in a much simplier COM interop call.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there any way to make a single control usable on both Windows Forms and Web Forms?
|
|
|
|
|
Interesting question... doesn't a forms control have to inherit from System.Windows.Forms.Control and a web control System.Web.UI.Control in order to function correctly in their repsective environments?
Are you looking to make any control in particular?
|
|
|
|
|
yup actually i was thinking why repeat the code for them separately but looks like it is not possible to do so on the lines of Activex controls , they were usable in both kinds of apllications. Intersting thing is that , since Windows forms control is derived from Component class and Any Component derived from Component class can be used in a web page. IF that is right then why can't we use a Windows Forms control in a Web Page?
|
|
|
|
|
Muhammad Nauman Khan wrote:
IF that is right then why can't we use a Windows Forms control in a Web Page?
You can. There are 2 ways to do this. One way is to create a .Net .exe as usual, then just navigate to the executable on the webserver; IE will use IEExec.exe to run the .exe in a sandbox. If your application is a Windows Forms app, the Form will be displayed as a new window.
Another option is to compile a System.Windows.Forms.UserControl as a .dll library, then reference that dll in an html's object tag like so
<object
="" id="anID
" classid="http:myAssemblyDll.dll#namespaceHere.ClassToInstanciateHere" height="300" width="300">
Where namespaceHere is the namespace containing the class to instanciate, and ClassToInstanciate is the name of the class whose constructor to call.
When using the latter method (UserControls in html), the UserControl will appear embedded inside the webpage, much like a Java applet would. For more information on using .Net assemblies in Internet Explorer, see www.csharphelp.com/archives/archive109.html or http://www.windowsforms.net/Forums/ShowForum.aspx?tabIndex=1&tabId=41&ForumID=17
Both of these options will work even from non-IIS servers such as Apache, buth there's more server scripting code needed to be done in order to get it to work on non-IIS servers.
Another option is the newly released (first released on Oct 6th) J# browser controls[^] Basically you could use them much like you would Java applets. If you don't like J#, you could write a small front-end in J# that would simply launch one of your C# assemblies.
The graveyards are filled with indispensible men.
|
|
|
|
|
Thought I'd throw up an example. Have a look at this System.Windows.Forms.UserControl embedded in an html page: http://www.pressenter.com/~bhimango/t3.html
It's simply a user control with a button and a tree view. Click the button to add a node to the treeview.
Unfortunately, IEExec doesn't interpret system colors, which is why all the controls have a white background. :P
The graveyards are filled with indispensible men.
|
|
|
|
|
To add good scripting support, see my article on DevHood at http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=388. I'm porting this and expanding upon it in several ways to move it over the CP by the end of the month.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|