Winfrom 样式设计 winform布局设计table 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用tablelayoutpanel或者datagridview,也可以用webbrowser+网页。 datagridview,边线可以通过cellpainting事件绘制,网上也有多表头的改进版 datagridview单元格边线可以设置颜色 第三方控件,Devexpress中的GridControl,使用Band列模式 +1最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value"); +1最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value");用webBrowser到是可以,不过没有在winform中用过。在webBrowser中能不能用js啊?主要是用js来限制输入框的输入内容,比如说限制输入金额类型、限制只能输入数字、只能输入中文等? 或者有没有其他好的方式来进行验证。 js只需要用在html里就可以了,在webbrowser里打开html之后,你只需要操作html即可,这样就不需要在后台写cs代码了,前提是得把html里引用js和css文件的路径设置正确 也就是webbrowser只需要做一件事情this.webBrowser.Navigate(@"..\test.html");数据验证之类的就由js来完成,样式在css里设置就可以了 方法很多如果单纯用控件的话推荐DEV,很强大 +1最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value");用webBrowser到是可以,不过没有在winform中用过。在webBrowser中能不能用js啊?主要是用js来限制输入框的输入内容,比如说限制输入金额类型、限制只能输入数字、只能输入中文等? 或者有没有其他好的方式来进行验证。 webbrowser就不需要js了,C#操作控制 htmldocument 。 GridView控件设置不同行的背景色样式 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="产品编号" ShowFooter="True" Width="624px" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound" onpageindexchanging="GridView1_PageIndexChanging" PageSize="5" ForeColor="Black" GridLines="Vertical"> <FooterStyle BackColor="#CCCC99" /> <Columns> <asp:BoundField DataField="产品编号" HeaderText="产品编号" InsertVisible="False" ReadOnly="True" SortExpression="产品编号" /> <asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价" /> <asp:BoundField DataField="库存量" HeaderText="库存量" SortExpression="库存量" /> <asp:BoundField DataField="已订购量" HeaderText="已订购量" SortExpression="已订购量" /> <asp:TemplateField HeaderText="订货金额" SortExpression="订货金额"> <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("订货金额", "{0:c}") %>'></asp:Label> </EditItemTemplate> <FooterTemplate> <asp:Label ID="OrderTotalLabel" runat="server" Font-Underline="True" ForeColor="Red"></asp:Label> </FooterTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("订货金额", "{0:c}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="订单日期"> <EditItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Eval("订单日期","{0:d}") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("订单日期","{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> <RowStyle BackColor="#F7F7DE" /> <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> <PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="#F7F7DE" /> <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView>//绑定显示数据设置背景色 public void DbBind() { string strCon = ConfigurationSettings.AppSettings["ConnectionString"]; string strsql = "SELECT 产品编号, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm"; SqlConnection myConn = new SqlConnection(strCon); if (myConn.State.Equals(ConnectionState.Closed)) myConn.Open(); SqlDataAdapter da = new SqlDataAdapter(strsql, strCon); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); } protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { // 提取当前的数据行。 GridViewRow row = e.Row; // 如果正被创建的数据行是一个脚注,则更新数据列加总。 if (row.RowType == DataControlRowType.Footer) { // 取得脚注当中的标签控件 OrderTotalTotal 。 Label total = (Label)(e.Row.FindControl("OrderTotalLabel")); // 以货币格式来显示订货金额加总。 if (total != null) { total.Text = orderTotal.ToString("c"); } } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // 确认“库存量”字段的值。 // 我们通过一个 DataBinder.Eval() 调用从将被绑定到 GridView 数据行的 // 数据中取得“库存量”字段的值,传递给 DataBinder.Eval() 的第一个参 // 数是将被绑定到 GridView 数据行的数据(也就是 e.Row.DataItem), // 传递给 DataBinder.Eval() 的第二个参数则是字段名称。 decimal stock = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "库存量")); if (stock <= 0) { // 如果库存量小于或等于 0,则将该数据行的背景色设置成红色。 e.Row.BackColor = Color.Red; } decimal totalMoney = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "订货金额")); if (totalMoney > 0) { // 如果订货金额大于 0,则将该数据行的背景色设置成黄色。 e.Row.BackColor = Color.Yellow; } orderTotal += totalMoney;// 累加订货金额并赋给变量 orderTotal。 } } winfrom 用 GDI+ 效果棒棒滴。 大婶们好webBrowser 加载完成事件里面再触发显示。 1 没显示前用半透明 argb 80,0,0,0 这样一个panel 感觉很好。 visual studio 2010 为什么操作一下就卡死了 如何在删除dataGridView中的记录,并且是真正的执行数据库删除? 用webbrowser如何只显示网页中的其中一个frame 模板引擎是怎么实现的 十六进制与汉字转换? 求实现一个简单的功能,急! 如何弹出目录浏览,而不是浏览文件? 【新手求助} numericUpDown控件问题 计算器中Button的快捷键及数值转换问题 谁来帮帮我????? 窗口设置背景图片后,Label显示速度慢 请教C# 像这样的情况,开多少线程是好?
最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value");
最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value");用webBrowser到是可以,不过没有在winform中用过。在webBrowser中能不能用js啊?主要是用js来限制输入框的输入内容,比如说限制输入金额类型、限制只能输入数字、只能输入中文等? 或者有没有其他好的方式来进行验证。
如果单纯用控件的话推荐DEV,很强大
最简洁的做法就是用html + css做出表格的样式,然后把表格嵌入到webbrowser控件里面,这样做可以很方便地修改表格的样式;取控件值的话就用webBrowser1.Document.GetElementById("控件ID").GetAttribute("value");用webBrowser到是可以,不过没有在winform中用过。在webBrowser中能不能用js啊?主要是用js来限制输入框的输入内容,比如说限制输入金额类型、限制只能输入数字、只能输入中文等? 或者有没有其他好的方式来进行验证。
webbrowser就不需要js了,C#操作控制 htmldocument 。
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" DataKeyNames="产品编号"
ShowFooter="True" Width="624px"
OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound"
onpageindexchanging="GridView1_PageIndexChanging" PageSize="5"
ForeColor="Black" GridLines="Vertical">
<FooterStyle BackColor="#CCCC99" />
<Columns>
<asp:BoundField DataField="产品编号" HeaderText="产品编号" InsertVisible="False" ReadOnly="True"
SortExpression="产品编号" />
<asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价" />
<asp:BoundField DataField="库存量" HeaderText="库存量" SortExpression="库存量" />
<asp:BoundField DataField="已订购量" HeaderText="已订购量" SortExpression="已订购量" />
<asp:TemplateField HeaderText="订货金额" SortExpression="订货金额">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("订货金额", "{0:c}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="OrderTotalLabel" runat="server" Font-Underline="True" ForeColor="Red"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("订货金额", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="订单日期">
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("订单日期","{0:d}") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("订单日期","{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="#F7F7DE" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
//绑定显示数据设置背景色
public void DbBind()
{
string strCon = ConfigurationSettings.AppSettings["ConnectionString"];
string strsql = "SELECT 产品编号, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 FROM tb_OrderForm";
SqlConnection myConn = new SqlConnection(strCon);
if (myConn.State.Equals(ConnectionState.Closed))
myConn.Open();
SqlDataAdapter da = new SqlDataAdapter(strsql, strCon);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
myConn.Close();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
// 提取当前的数据行。
GridViewRow row = e.Row;
// 如果正被创建的数据行是一个脚注,则更新数据列加总。
if (row.RowType == DataControlRowType.Footer)
{
// 取得脚注当中的标签控件 OrderTotalTotal 。
Label total = (Label)(e.Row.FindControl("OrderTotalLabel")); // 以货币格式来显示订货金额加总。
if (total != null)
{
total.Text = orderTotal.ToString("c");
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// 确认“库存量”字段的值。
// 我们通过一个 DataBinder.Eval() 调用从将被绑定到 GridView 数据行的
// 数据中取得“库存量”字段的值,传递给 DataBinder.Eval() 的第一个参
// 数是将被绑定到 GridView 数据行的数据(也就是 e.Row.DataItem),
// 传递给 DataBinder.Eval() 的第二个参数则是字段名称。
decimal stock =
Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "库存量"));
if (stock <= 0)
{
// 如果库存量小于或等于 0,则将该数据行的背景色设置成红色。
e.Row.BackColor = Color.Red;
}
decimal totalMoney =
Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "订货金额"));
if (totalMoney > 0)
{
// 如果订货金额大于 0,则将该数据行的背景色设置成黄色。
e.Row.BackColor = Color.Yellow;
}
orderTotal += totalMoney;// 累加订货金额并赋给变量 orderTotal。
}
}