如何在Windows窗体中显示数据库中的所有内容并在其附近显示编辑按钮 [英] how do display all contents in a database in windows form and show an edit button near it

查看:87
本文介绍了如何在Windows窗体中显示数据库中的所有内容并在其附近显示编辑按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个Windows窗体来显示数据库中的所有记录并仅隐藏密码字段.....



然后显示一个编辑按钮附近它。

如果我点击编辑按钮然后它们可以编辑,也可以只读。



如何在Windows窗体中执行此操作

I want a windows form to show all the records in a database and hide only the password field with .....

Then show a edit button near it.
If I click edit button then they can be editable else read only.

How to do this in windows forms

推荐答案

回答问题的第一部分:

我假设您的数据将显示在名为'dgvData'的DataGridView组件中。

要隐藏特定列中的数据,您可以使用DGV CellFormatting事件。像这样创建事件处理程序:



Answer to the first part of your question:
I assume that your data will be displayed at DataGridView component named 'dgvData'.
To hide data in particular column you can use DGV CellFormatting event. Create event handler like this:

private void dgvData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
    if (e.ColumnIndex == 2)   // Here you need to insert valid column number which displays your password field
    {
        e.Value = "*****";
    }
}





第二部分问题对我来说是不可理解的。请再解释一下。



Second part of question is incomprehensible to me. Please explain it a little bit more.


这篇关于如何在Windows窗体中显示数据库中的所有内容并在其附近显示编辑按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆