|
Ummm, what about trying:
lbDateTime.Text = DateTime.Now.ToString();
- Nick Parker My Blog
|
|
|
|
|
KoalaCowboy wrote:
Gang,
Background: I am trying to have a label (lblDateTime1) display DateTime.Now upon application load (Windows Form). I have done something similar in VB.NET as follows:
///VB.NET code
{
lblDateTime = DateTime.NOW.ToString()
}
///C# code
{
///Insert example here please
private void Form1_Load(object sender, System.EventArgs e)
{
textBox1.Text = DateTime.Now.ToString();
}
}
RageInTheMachine9532
|
|
|
|
|
Hello ,
Can anyone please help me, on how I go about adding a footer like the one available for the asp.net datagrid, to a windows form datagrid??
Thank you!
|
|
|
|
|
Doesn't exist on the Windows Forms DataGrid . Just add a summary row or a control (or controls) below the DataGrid on your form.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm trying to create an Interop class in C# and use it as a COM object in VBA. After numerous failed attempts in my own code I tried with a simple example. This is what I have done:
using System;
namespace BeeComTest
{
public interface ITest
{
System.DateTime GetTime();
}
public class Test : ITest
{
public Test()
{
}
#region ITest Members
public DateTime GetTime()
{
return System.DateTime.Now;
}
#endregion
}
}
Compiled it into a dll called: BeeComTest.dll
(have strong signed it)
Next I ran from the command line:
gacutil /i BeeComTest.dll
tlbexp BeeComTest.dll
Then I opened up Excel and VBA:
Selected BeeComTest from Tools/References
The VBA Code used is:
__________________________________
Dim NetTest As BeeComTest.ITest
Sub Test()
Set NetTest = CreateObject("BeeComTest.test")
//Comment have also tried setting via following
//command, same error
// Set NetTest = New BeeComTest.Test
Debug.Print ".Net server returned: " + FormatDateTime (NetTest .GetTime, vbGeneralDate)
End Sub
__________________________________
Problem:
When I run the Macro (in debug stepping through the code) I get the following errow when the object is being Set...
Run-time error '429':
ActiveX component can't create object
Then the code exits.
I have searched far and wide and can't find any useful advice/help. If anyone has any idea's or suggestions why the COM object isn't being created it would be greatly appreciated.
Many thanks,
Bee
|
|
|
|
|
|
Thanks for reply Nick Good article! I will give it a test run first thing tomorrow morning and let you know how I fare!
|
|
|
|
|
Hi
How can insert a image or read it and show in ado.net?
i want to store image (for exmaple .jpg or bmp) in database and show them in form(with which controls??)
Regards' Amirjalay
|
|
|
|
|
SQL database can accept the Binary type, which corresponds to an C# byte[]. So convert your bitmap into an array of bytes when you want to store it in the database. And when you're ready to read it from the database, construct one from the read in bytes (you should be able to use something like Bitmap.FromStream).
The graveyards are filled with indispensible men.
|
|
|
|
|
|
This has been covered many times in this forum. Please click "Search comments" above. One specific thread not so long ago can be found here[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
1. Create a binary column in your database large enough to store the picture (image is a good choice).
2. Stream the target picture (System.Drawing.Image instance or whatever) to a byte array (I generally use the System.IO.MemoryStream class and the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter to create the byte stream for writing to the DB)
Example Image Encode:
=====================
Image myImage = Image.FromFile(filePath);<br />
MemoryStream stream = new MemoryStream();<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
formatter.Serialize(stream, myImage);<br />
<br />
byte[] imageBytes = stream.GetBuffer();<br />
<br />
3. To retrieve the target image, load the row containing it, and get the byte array from the column containing the image data, then use the System.Drawing.Image.FromStream static method to instantiate a new Image instance.
hope this helps...
No design ever survives first contact with its users.
|
|
|
|
|
I am interested in creating an application that will write to cds from a web server but the files that it will first be in mp3 format first then the program will change the files into cda format to be burned to a cd. Could you please give me some direction?
Da Intern
|
|
|
|
|
There is library written by MS which exists in their site, its berning CD in .NET. Search MSDN for it,I don't have the link now.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
thanks for your help I have found that link now im trying to convert mp3 files to CDA files to burn onto the CD
Da Intern
|
|
|
|
|
Hello everyone,
I have a ASP.Net application which has crystal reports. For a batch process I want to create a console application in the same solution. Batch process takes about 2 or more hours to complete, console application would b a better solution as of my knowledge (if anyone has any suggestion, plz let me know). Problem is that reports exist in asp.net project, how do I use the same reports and its .cs files in the console application? I don't want to create a duplicate copy of reports.
Thanks in advance
Ali Haider
|
|
|
|
|
Sorting DataGrid BoundColumn using DataGrid.SortCommand
I have DataGrid control and I am adding BoundColumns at runtime.
My Questions are:
1) I need to sort DataGrid using DataGrid.SortCommand and **NOT** OnSortCommand as I am using CodeBack file.
2) I also need to Hide last column.
Below is code for aspx file
<%@ Page language="c#" Codebehind="DataGridSortingDemo.aspx.cs" AutoEventWireup="false" Inherits="Connection.DataGridSortingDemo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DataGridSortingDemo</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="DataGridSortingDemo" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server" AllowSorting="True" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
<ItemStyle ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
Below is code back (aspx.cs) file
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Connection
{
public class DataGridSortingDemo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
if( ! IsPostBack)
{
DataGrid1.DataSource = CreateDataSource();
DataGrid1.DataBind();
}
}
protected DataView CreateDataSource()
{
string strConnectionString = "user id=sa;password=;Database=Northwind;Server=localhost";
string strSQLQuery = "SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, 1 FROM Customers";
DataTable objDT = new DataTable();
BoundColumn objBoundColumn;
SqlConnection objSQLConn = new SqlConnection(strConnectionString);
SqlDataAdapter objSQLDA = new SqlDataAdapter(strSQLQuery, objSQLConn);
objSQLConn.Open();
objSQLDA.Fill(objDT);
objSQLConn.Close();
DataGrid1.AutoGenerateColumns = false;
for (int intCounter = 0; intCounter < objDT.Columns.Count; intCounter++)
{
objBoundColumn = new BoundColumn();
objBoundColumn.HeaderText = objDT.Columns[intCounter].ColumnName;
objBoundColumn.DataField = objDT.Columns[intCounter].ColumnName;
objBoundColumn.SortExpression = objDT.Columns[intCounter].ColumnName;
DataGrid1.Columns.Add(objBoundColumn);
}
DataView dvCommonDataView = new DataView(objDT);
return dvCommonDataView;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.DataGrid1.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.DataGrid1_SortCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
Response.Write("Hi There");
}
}
}
|
|
|
|
|
First please please delete your duplicate LONG message.
Second: You have to try this on ASP.NET furom.
ajaylulia wrote:
2) I also need to Hide last column.
Set Visible property to false.
ajaylulia wrote:
1) I need to sort DataGrid using DataGrid.SortCommand and **NOT** OnSortCommand as I am using CodeBack file.
The place for sorting is there and you havve to set SortExpression there. Why do you say you don't want to do it in that event?
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
1) The above code which I posted is working fine, but does not trigger DataGrid.SortCommand Event, when using BoundColumn. If I comment BoundColumn Code and set the DataGrid.AutoGenerateColumns to true, then the DataGrid.SortCommand Event in code back file is triggered properly.
2) If I dont use BoundColumn then I cannot set the Visible for last column (eg. Column No 7) to false, as DataGrid.Columns.count is always 1. The reason I get DataGrid.Columns.count as 1 is because first column in DataGrid is Template Column.
Ajay Lulia
|
|
|
|
|
When using non-blocking I/O in C++ a simple send() call could fail with WSAEWOULDBLOCK and the data is put in a message queue. When a FD_WRITE is coming in you can try send it again.
I wonder if this can happen with asynchronous sockets in .NET?
Can a send fail with WSAEWOULDBLOCK so that I need to use a message queue or does the framework do the second send for me?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
This was already answered earlier (and many times before that) here[^]. Please click "Search comments" above before posting, because many questions have already been discussed many times.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
I am developing an ASP.NET C# Mobile Application. It works fine when I run it in a browser but if I run it on the openwave WAP emulator it is giving me an error, Malformed server response, when I try to go to the next page. I was thinking it might have something to do with the function I am calling to get it to go onto the next page, the function is RedirectToMobilePage(url). Any suggestions would be great.
Thanx
Rosie
|
|
|
|
|
Is this a server- or client-side function? Are you sure that WAP implements a scripting engine for Javascript? I honestly don't know since I've never cared to deal with mobile apps.
If this is a server-side method, are you canceling the response or letting the response complete. In most cases, you want the latter, otherwise an exception will be thrown if not handled correctly. So you should call RedirectToMobilePage(url, false); .
Also, this really belongs in the ASP.NET forum for future reference.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i can't load a Mesh into my directx App as it views as empty one
but when i see it in the mesh viewer utility it is there and i can see it
|
|
|
|
|
Sounds like you're not resolving the path to the file correctly. If your .X file is stored as a separate file, make sure you take the current working directory into account (may not be the application base), or use the application base by using Assembly.GetExecutingAssembly().Location . IIRC, the Mesh class can also accept a Stream , so if you embedded the .X file as an embedded resource, you can use Assembly.GetManifestResourceStream to get an instance of a Stream for the resource.
Microsoft MVP, Visual C#
My Articles
|
|
|
|