最近作一个C#工具中遇到的几个难题,非高手莫入

xxj 2003-04-04 11:03:18
1、如何将父类的保护成员到子类中改成公有的成员

如何屏蔽已有控件的可浏览属性,如,你在做一个控件时,
可以设定属性 [Browsable(false)]
2、如何调用生成ADO连接字符串的对话框

3、如何知道一个oleDbConnection连接的数据库,数据表列表
(大型数据库很好获取,但对于象Access,Excel,Foxpro,Paradox,Text数据库该如何获取)

4、高亮度语法编辑器
(有人建议使用RichText作,确实可以的,但很短时间内作一个比较完善的,不太容易
C#有类似于Delphi中的MWedit、SynEdit的控件吗)
...全文
26 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxj 2003-04-10
  • 打赏
  • 举报
回复
谢谢以上各位!
本来还有一个问题,鼠标活动范围的锁定:今天自己解决了,献丑了:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
public class Common
{
[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern bool ClipCursor(ref RECT lpRect);

/// <summary>
/// 使鼠标在指定的范围内活动
/// </summary>
/// <param name="C"></param>
public static void ClipCursorIn(System.Windows.Forms.Control C)
{

Crownwood.Magic.Win32.RECT R;
Point P=C.PointToScreen(C.Location);
R.left=P.X;
R.top=P.Y;
R.right=R.left+C.Width;
R.bottom=R.top+C.Height;
ClipCursor(ref R);
}
/// <summary>
/// 恢复鼠标的活动范围
/// </summary>
public static void RestoreCursor()
{
Crownwood.Magic.Win32.RECT R;
//Point P=
R.left=0;
R.top=0;
R.right=Screen.PrimaryScreen.Bounds.Width;
R.bottom=Screen.PrimaryScreen.Bounds.Height;
ClipCursor(ref R);
}
}

cometsky 2003-04-08
  • 打赏
  • 举报
回复
关于用RichTextBox作代码编辑器基本上不用考虑,一是闪烁,二是效率低下。比较可行的就是用GDI+自己画。
shenfuhua 2003-04-07
  • 打赏
  • 举报
回复
http://www.microsoft.com/china/msdn/library/dndotnet/html/usingpropgrid.asp
wuzhiwen 2003-04-07
  • 打赏
  • 举报
回复
答:如何屏蔽已有控件的可浏览属性,如,你在做一个控件时,
可以设定属性 [Browsable(false)]?因为控件的可见性是依赖其父控件的可见性的,所以你设置父控件的可见性即可
LiSDN 2003-04-07
  • 打赏
  • 举报
回复
"非高手莫入"-----好象有點*眼看人低哦

呵呵﹐講笑了

UP一下
gengwei80 2003-04-07
  • 打赏
  • 举报
回复
up
tjtao 2003-04-05
  • 打赏
  • 举报
回复
UP
whxbb 2003-04-05
  • 打赏
  • 举报
回复
3、如何知道一个oleDbConnection连接的数据库,数据表列表

public DataTable GetTables(OleDbConnection conn)
{
conn.Open();
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
conn.Close();
return schemaTable;
}
whxbb 2003-04-05
  • 打赏
  • 举报
回复
2、如何调用生成ADO连接字符串的对话框

using System;

using System.Windows.Forms;

namespace Whxbb.Windows.Forms
{
/// <summary>
/// 数据库选择对话框。
/// </summary>
public class ChooseDatabaseDialog
{
private string _connectionString = String.Empty;
/// <summary>
/// 获取数据库连接字符串。
/// </summary>
public string ConnectionString
{
get
{
if (_connectionString == string.Empty && _connectionString != "")
{
return _connectionString;
}
else
{
string[] tmp = _connectionString.Split(';');
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for(int i = 1; i < tmp.Length; i++)
{
if (i != 1)
sb.Append(";" + tmp[i]);
else
sb.Append(tmp[i]);
}
return sb.ToString();
}

}
}

private MSDASC.DataLinks _dataLinks;
private ADODB.Connection _connection;

/// <summary>
/// 无参数构造方法。
/// </summary>
public ChooseDatabaseDialog()
{
_dataLinks = new MSDASC.DataLinksClass();
}

/// <summary>
/// 显示对话框。
/// </summary>
/// <returns></returns>
public DialogResult ShowDialog()
{
try
{
_connection = new ADODB.ConnectionClass();
//_connection = (ADODB.Connection)_dataLinks.PromptNew();
_connection.Provider = "SQLOLEDB.1";

object obj = _connection as object;
_dataLinks.PromptEdit(ref obj);
if (_connection == null)
{
return DialogResult.Cancel;
}
else
{
_connectionString = _connection.ConnectionString;
if (_connectionString == "" || _connectionString == null)
{

return DialogResult.Cancel;
}
else
{
return DialogResult.OK;
}
}
}
catch (Exception e)
{
return DialogResult.Abort;
}
}
}

}

记得引用 .net程序集adodb 和 com 组件micorsoft ole db service component 1.0 type library。具体用法我自己还在摸索中。

whxbb 2003-04-05
  • 打赏
  • 举报
回复
1 如何将父类的保护成员到子类中改成公有的成员
public class Test
{
protected string SayHelloTo(string name)
{
return "hello," + name;
}
}
public class MyTest : Test
{
new public string SayHelloTo(string name)
{
return base.SayHelloTo(name);
}
}
tms2000 2003-04-05
  • 打赏
  • 举报
回复
1、如何将父类的保护成员到子类中改成公有的成员
回答:delphi可以这样做,c#不可以,只能变通呀,(老弟应该是vcl出神吧)
2、如何调用生成ADO连接字符串的对话框
在oledb哪个com单元里,有显示这个筐的方法。

3、如何知道一个oleDbConnection连接的数据库,数据表列表
(大型数据库很好获取,但对于象Access,Excel,Foxpro,Paradox,Text数据库该如何获取)
哦,Excel (可以配好连接以后 select * from [sheet1]) 其他access foxpro paradox用oledb方法操作很简单,对于ASCII的表(text) 不知道有没有ole驱动支持,想办法用fileStream读吧
4、高亮度语法编辑器
高亮度语法显示,用richtext,对与rtf串,可以用office带的 一个com 给分,我给你说,不骗你呀。。。哈
reddust 2003-04-04
  • 打赏
  • 举报
回复
高亮度语法编辑器

RichTextBox可以做,也不太费劲,就是闪烁解决不了,哪位兄弟搞定了?
glboy 2003-04-04
  • 打赏
  • 举报
回复
3.通过ADO.NET从数据库中获取架构信息是可以的
seabirdforever 2003-04-04
  • 打赏
  • 举报
回复
1
对于 基类中的 保护成员 在程序中不运行直接访问,必须是 他的字类才可以访问
但我们可以通过
在 子类中定义 公有成员, 把 基类的 保护 成员 值赋给它
这样在程序中调用 字类 公有成员 的值 其实就是 基类 保护成员 的值了
huan_jinwu 2003-04-04
  • 打赏
  • 举报
回复
gzing......

110,477

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧