社区
VC.NET
帖子详情
请问vc.net怎样添加已有的.cs文件
xinustc
2009-03-24 07:37:38
想通过实例学习,可是连运行都不会 汗...
如果直接打开则编译不用,通过新建项目,却不知道怎么添加.cs文件,高手莫笑
...全文
95
7
打赏
收藏
请问vc.net怎样添加已有的.cs文件
想通过实例学习,可是连运行都不会 汗... 如果直接打开则编译不用,通过新建项目,却不知道怎么添加.cs文件,高手莫笑
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Grave_rain
2009-03-24
打赏
举报
回复
没懂,看看!!
vrhero
2009-03-24
打赏
举报
回复
VC是不可能编译C#代码的...虽然.NET支持多语言但是不支持混合语言,这点你要搞清楚...
xinustc
2009-03-24
打赏
举报
回复
现在加进去了 但是无法编译通过 是版本的问题 已有的程序是vc2002编译的 我想把它在vc2008下编译
不知道怎么弄- -
程序很简单 就一个cs文件:
form.cs
**********************************************************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace myFirstWinApp
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txt_input;
private System.Windows.Forms.Button btn_ok;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txt_input = new System.Windows.Forms.TextBox();
this.btn_ok = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// txt_input
//
this.txt_input.Location = new System.Drawing.Point(88, 64);
this.txt_input.Name = "txt_input";
this.txt_input.TabIndex = 0;
this.txt_input.Text = "朋友,你好!";
//
// btn_ok
//
this.btn_ok.Location = new System.Drawing.Point(104, 128);
this.btn_ok.Name = "btn_ok";
this.btn_ok.TabIndex = 1;
this.btn_ok.Text = "我想说";
this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btn_ok,
this.txt_input});
this.Name = "Form1";
this.Text = "我的第一个Windows应用程序";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btn_ok_Click(object sender, System.EventArgs e)
{
MessageBox.Show(txt_input.Text, "Hello");
}
}
}
chensan
2009-03-24
打赏
举报
回复
你可能没有安装完整,只安装vc的工程。
Dobzhansky
2009-03-24
打赏
举报
回复
要编译 c sharp, 建立 c# 的工程啊, visual studio 不是只支持 vc 一种工程类型的
xinustc
2009-03-24
打赏
举报
回复
我就是要编译c sharp啊
宝_爸
2009-03-24
打赏
举报
回复
cs是C#的源文件,不是VC++的源文件。
★VisualStudio 2015 如何将aspx.
cs
代码编译为dll.docx
用ASP
.net
做网站的时候,源码中有很多aspx.
cs
源
文件
,放在服务器上很不安全,同时也不好保护知识产权,把它们编译为dll
文件
,这样可以起到保护源码的作用。在VS2015里怎么操作呢?
VC
.net
异步装载大图像
文件
实例代码.rar
VC
.net
异步装载大图像
文件
演示
文件
,适时显示装载进度条,挺基础的一个例子源代码。
Error 1935 | Assembly component Microsoft.
VC
80.CRT
Error 1935 | Assembly component Microsoft.
VC
80.CRT | Install |
CS
4,
CS
5,
CS
5.5 products | Windows
VC
++(VS2010)读写Excel
文件
代码(附示例)
【前言】 工作或学习中可能需要实现基于
VC
读\写Excel
文件
的功能,本人最近也遇到了该问题。中间虽经波折,但是最终还是找到了解决问题的办法。 在此跟大家分享,希望对跟我同样迷茫过的同学们有所帮助。 1、程序功能 1)打开一个excel
文件
; 2)显示到CListCtrl上; 3)新建一个Excel
文件
。 以上均在对话框中实现。 2、平台
VC
++2010 3、实现方法 常用的Excel打开方式有两种 1)通过数据库打开; 2)OLE方式打开。 由于方式1)操作繁琐,经常出现莫名的错误,这里选用方式2). 4、准备步骤 首先新建一个Dialog窗体程序,
添加
list control和两个按钮 1)将ExcelLib
文件
夹拷贝到程序目录下; 2)将Export2Excel.h,Export2Excel.cpp两个
文件
添加
到项目; 3)包含头
文件
,#include "ExcelLib/Export2Excel.h" 通过以上步骤在程序中引入了可以读取Excle
文件
的CExport2Excel类; 5、打开excel
文件
通过按钮点击打开 void CExcelTestDlg::OnBnClickedButtonOpenExcel() { //获取
文件
路径 CFileDialog* lpszOpenFile;
CS
tring szGetName; lpszOpenFile = new CFileDialog(TRUE,"","",OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"Excel File(*.xlsx;*.xls)|*.xls;*.xlsx",NULL); if (lpszOpenFile->DoModal()==IDOK) { szGetName = lpszOpenFile->GetPathName(); SetWindowText(szGetName); delete lpszOpenFile; } else return; //打开
文件
//
文件
中包含多个sheet时,默认打开第一个sheet CExport2Excel Excel_example; Excel_example.OpenExcel(szGetName); //获取sheet个数 int iSheetNum = Excel_example.GetSheetsNumber(); //获取已使用表格行列数 int iRows = Excel_example.GetRowCount(); int iCols = Excel_example.GetColCount(); //获取单元格的内容
CS
tring
cs
_temp = Excel_example.GetText(1,1); //AfxMessageBox(
cs
_temp); //List control上显示 //获取工作表列名(第一行)
CS
tringArray m_HeadName; m_HeadName.Add(_T("ID")); for (int i=1;iGetItemCount()>0) { m_list.DeleteColumn(0); } //初始化ClistCtrl,加入列名 InitList(m_list,m_HeadName); //填入内容 //第一行是标题,所以从第2行开始
CS
tring num; int pos; for (int row = 2;row<=iRows; row++) { pos = m_list.GetItemCount(); num.Format(_T("%d"),pos +1); m_list.InsertItem(pos,num); for (int colum=1;columDoModal()==IDOK) { szGetName = lpszOpenFile->GetPathName(); SetWindowText(szGetName); delete lpszOpenFile; } else return; //
文件
全名称
CS
tring
cs
FileName = szGetName; //需要
添加
的两个sheet的名称
CS
tring
cs
SheetName = "newSheet";
CS
tring
cs
SheetName2 = "newSheet2"; // 新建一个excel
文件
,自己写入文字 CExport2Excel Excel_example; //新建excel
文件
Excel_example.CreateExcel(
cs
FileName); //
添加
sheet,新加的sheet在前,也就是序号为1 Excel_example.CreateSheet(
cs
SheetName); Excel_example.CreateSheet(
cs
SheetName2); //操作最开始
添加
的sheet:(newSheet) Excel_example.SetSheet(2); //
添加
表头 Excel_example.WriteHeader(1,"第一列"); Excel_example.WriteHeader(2,"第二列"); //
添加
核心数据 Excel_example.WriteData(1,1,"数据1"); Excel_example.WriteData(1,2,"数据2"); //保存
文件
Excel_example.Save(); //关闭
文件
Excel_example.Close(); } 7、注意事项 1)一般单个Excel
文件
包含多个sheet,程序默认打开第一个; 2)指定操作sheet,使用Excel_example.SetSheet(2)函数; 3)打开
文件
时最左侧的sheet序号为1,新建excel时最新
添加
的sheet序号为1. 【后记】 本程序主要基于网络
CS
DN中---“Excel封装库V2.0”---完成,下载地址是:http://download.
cs
dn
.net
/detail/yeah2000/3576494,在此表示感谢!同时, 1)在其基础上作了小改动,改正了几个小错误,
添加
了几个小接口; 2)
添加
了如何使用的例子,原程序是没有的; 3)详细的注释 发现不足之处,还请大家多多指教!
VC
,C#访问USB端口类
VC
,C#访问USB端口类实例,遍例USB端口,查找打开端口。
VC.NET
7,539
社区成员
27,671
社区内容
发帖
与我相关
我的任务
VC.NET
.NET技术 VC.NET
复制链接
扫一扫
分享
社区描述
.NET技术 VC.NET
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章