Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Datagridview,获取现有列并使其成为超链接_C#_Datagridview_Hyperlink - Fatal编程技术网

C# 使用Datagridview,获取现有列并使其成为超链接

C# 使用Datagridview,获取现有列并使其成为超链接,c#,datagridview,hyperlink,C#,Datagridview,Hyperlink,myDataGridView中的第五列是从SQL server中的resumelink中提取信息。文件名是简历链接记录中唯一的内容,例如DOC100.pdf或Name12.pdf。我需要这些文件链接到计算机上的映射驱动器,因此,如果文件名是DOC100.pdf,则它必须是//nt/resume/DOC100.pdf。我需要存储//nt/resume部分,然后在resumelink字段中添加内容。我有一个名为dataGridView1\u CellContentClick的字段,但它当前为空。我不

my
DataGridView
中的第五列是从SQL server中的
resumelink
中提取信息。文件名是简历链接记录中唯一的内容,例如DOC100.pdfName12.pdf。我需要这些文件链接到计算机上的映射驱动器,因此,如果文件名是DOC100.pdf,则它必须是
//nt/resume/DOC100.pdf
。我需要存储
//nt/resume
部分,然后在resumelink字段中添加内容。我有一个名为
dataGridView1\u CellContentClick的字段,但它当前为空。我不关心pdf是如何打开的,不管它是在IE还是Adobe中

这是一张程序的图片

namespace ResumeTest
{
public partial class Resume : Form
{
    SqlConnection conn = new SqlConnection();

    public Resume()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'iHBAPPSDataSet.HRresume' table. You can move, or remove it, as needed.
       this.hRresumeTableAdapter.Fill(this.iHBAPPSDataSet.HRresume);
       this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.White;
       this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine;
    }


    private void button1_Click(object sender, EventArgs e)
    {
       bindingSource1.Filter = "name LIKE '%" + name.Text + "%' AND skillset LIKE '%" + skillset.Text + "%'";
    }

    public void ClearTextBoxes(Control control)
    {
        foreach (Control c in control.Controls)
        {
            if (c is TextBox)
            {
                if (!(c.Parent is NumericUpDown))
                {
                    ((TextBox)c).Clear();
                }
            }
            else if (c is NumericUpDown)
            {
                ((NumericUpDown)c).Value = 0;
            }
            else if (c is ComboBox)
            {
                ((ComboBox)c).SelectedIndex = 0;
            }

            if (c.HasChildren)
            {
                ClearTextBoxes(c);
            }
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {
        ClearTextBoxes(this);
        bindingSource1.Filter = "name LIKE '%" + name.Text + "%'";
    }

    private void button3_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void button4_Click(object sender, EventArgs e)
    {
        Add f2 = new Add();
        f2.Show();
    }

    private void button6_Click(object sender, EventArgs e)
    {
        Delete f3 = new Delete();
        f3.Show();
    }

    private void refreshButton_Click(object sender, EventArgs e)
    {
        this.hRresumeTableAdapter.Fill(this.iHBAPPSDataSet.HRresume);
    }

    private void quitToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }
  }
}

或者将所有内容放在一行:

Process.Start(@"//nt/resume/" + dataGridView1[e.ColumnIndex, e.RowIndex].Value);

另外,这不会改变datagrid中文件名的显示(我认为这比在一个单元格中显示长字符串(如
//nt/resume/DOC100.pdf
)更好),但会正确处理文件打开。

为什么不从sql server本身返回
'//nt/resume/'+resumelink作为resumelink
Process.Start(@"//nt/resume/" + dataGridView1[e.ColumnIndex, e.RowIndex].Value);