System.Windows.Forms.SaveFileDialog问题
最近遇到一BT要求。要求保存文件窗体中的combobox那个部分可以点后察看当前路径,但是不可以更改。就是不可以选择其他的文件夹。保存的文件路径必须是当前系统指定的。就是说 那些什么新建立文件夹啦,移动到桌面的那些快捷方式全部变成不可用。就给你留个文件名称让你手动输入。大家有办法没〉?????
谢谢
最近遇到一BT要求。要求保存文件窗体中的combobox那个部分可以点后察看当前路径,但是不可以更改。就是不可以选择其他的文件夹。保存的文件路径必须是当前系统指定的。就是说 那些什么新建立文件夹啦,移动到桌面的那些快捷方式全部变成不可用。就给你留个文件名称让你手动输入。大家有办法没〉?????
谢谢
http://www.codeproject.com/info/search.asp然后自己写个CustomSaveFileDialog吧
=====================================
老大你给我个search页面作什么啊。那上面的我找了。没感觉有比较合适的
涉及的问题会比较多
个人觉得改变外观相对来讲容易一些
首先得借助Spy++查看消息
然后在对话框初始化的时候调用SendMessage等API
改变其外观
string filePath = string.Empty;
string fileName = string.Empty;
string fileDir = string.Empty;
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (Char)Keys.Back)
{
if (comboBox1.Text == fileDir) e.Handled = true;
}
if (comboBox1.SelectionStart <= fileDir.Length)
{
if (e.KeyChar != (Char)Keys.RWin) e.Handled = true;
}
} private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
filePath = comboBox1.SelectedItem.ToString();
fileDir = Path.GetDirectoryName(filePath);
fileName = Path.GetFileName(filePath);
}目前来说, 还没怎么仔细test上面的code, 大致方向如此, 应该符合你的要求的
string fileName = string.Empty;
string fileDir = string.Empty;
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (Char)Keys.Back)
{
if (comboBox1.Text == fileDir) e.Handled = true;
}
if (comboBox1.SelectionStart <= fileDir.Length)
{
comboBox1.SelectionStart = fileDir.Length;
if (e.KeyChar != (Char)Keys.RWin) e.Handled = true;
}
} private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
filePath = comboBox1.SelectedItem.ToString();
fileDir = Path.GetDirectoryName(filePath);
fileName = Path.GetFileName(filePath);
}
请参考
http://www.codeproject.com/csharp/GetSaveFileName.asp然后按照这个大体思路去做
这是两种不同的方法
http://www.codeproject.com/cs/miscctrl/CustomizeFileDialog.asp