如何在DataGridView中添加另一行?

时间:2018-04-08 23:19:32

标签: c# forms datagridview rows cells

如何添加另一行 填充第一行[0]后?

    <!DOCTYPE html>
<html>
<head>
<style>
.screencontainer{
margin: 0 auto;
display: block;
xxheight: auto;
xxmax-width: 90%;
align-items: middle;
}

.foundations-wrapper{
display: inline-block;
background-color: yellow;
padding: 10px;
xxheight: auto;
margin: auto;
}
.foundations-content{
display: block;
width:200px;
height:50px;
background-color: lightblue;
margin: auto;
margin-top: 10px;
text-align: center;
color: white;
}
.foundations-button{
display: inline-block;
width:20px;
height:20px;
background-color: blue;
margin: auto;
margin: 10px;
text-align: center;
color: white;
}
.search-wrapper{
display: inline-block;
background-color: yellow;
padding: 10px;
xxheight: auto;
margin: auto;
}
.search-content{
display: inline-block;
height:50px;
width:200px;
background-color: lightblue;
margin: 0 auto;
text-align: center;
color: white;
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}

.titlebar{
display: block;
width:404px;
height:20px;
border-radius:10px;
background-color: red;
text-align: center;
color: white;
}
</style>
</head>
<body>
<div class="screencontainer" style="border: 1px solid black;">
<div class="titlebar">1</div>
<div class="foundations-wrapper">
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>
    <div class="foundations-content">1</div>

</div>
    <div class="foundations-wrapper">
        <div class="foundations-content">
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
        </div>
        <div class="foundations-content">
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
        </div>
        <div class="foundations-content">
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
            <div class="foundations-button">1</div>
        </div>
</div>


<div class="search-wrapper">
    <div class="search-content">1</div>
    <div class="search-content">1</div> 
</div>
</div>  
</body>
</html>

1 个答案:

答案 0 :(得分:0)

也许我认为你应该使用以下代码。

object [] values = new object [3];
values [0] = cbModello.Text;
values [1] = txtPlaca.Text;
values [2] = txtTotal.Text;

DTG.Rows.Insert (0,values); // insert at first