我正在使用Bootstrap,并绘制一个表格.最右边的列中有一个按钮,我希望它下拉到适合所述按钮所需的最小尺寸.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<table class="table table-responsive">
<tbody>
<tr>
<th>Name</th>
<th>Payment Method</th>
<th></th>
</tr>
<tr>
<td>Bart Foo</td>
<td>Visa</td>
<td><a role="button" class="btn btn-default btn-xs" href="/Payments/View/NnrN_8tMB0CkVXt06nkrYg">View</a></td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
这呈现如下:
随着一些firebug突出显示,列宽已经出现这么广泛:
该列与页面缩放,而页面处于较大的动态宽度模式.我知道如何在纯CSS中修复它,但大多数这些方法可能会导致网站的低宽度版本出现问题.
如何将该列下拉到其内容的宽度?
(一如既往 - 现有的bootstrap类>纯CSS> Javascript)
我在我当前的项目中做了大量的反思,我正在尝试提供一些帮助方法,以保持一切整洁.
我想提供一对方法来确定类型或实例是否实现IEnumerable
- 无论类型如何T
.这就是我现在所拥有的:
public static bool IsEnumerable(this Type type)
{
return (type is IEnumerable);
}
public static bool IsEnumerable(this object obj)
{
return (obj as IEnumerable != null);
}
Run Code Online (Sandbox Code Playgroud)
当我用它们测试它们时
Debug.WriteLine("Type IEnumerable: " + typeof(IEnumerable).IsEnumerable());
Debug.WriteLine("Type IEnumerable<>: " + typeof(IEnumerable<string>).IsEnumerable());
Debug.WriteLine("Type List: " + typeof(List<string>).IsEnumerable());
Debug.WriteLine("Type string: " + typeof(string).IsEnumerable());
Debug.WriteLine("Type DateTime: " + typeof(DateTime).IsEnumerable());
Debug.WriteLine("Instance List: " + new List<string>().IsEnumerable());
Debug.WriteLine("Instance string: " + "".IsEnumerable());
Debug.WriteLine("Instance DateTime: " + new DateTime().IsEnumerable());
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果:
Type IEnumerable: False …
Run Code Online (Sandbox Code Playgroud) 我正在使用Bootstrap-Datepicker,它运行得非常好.
我正在使用它的一个领域是出生日期,我知道申请人的大致年龄是多少,所以我有理由将默认选择器显示在2000年1月.
但是,我发现这样做的唯一方法是选择一个日期,实际上用一个值来更新字段,这是我不想要的.
$(document).ready(function () {
var datePickers = $('input[data-provide="datepicker"]');
datePickers.each(function () {
var datePicker = $(this);
datePicker.datepicker('setDate', new Date(2000, 1, 1));
});
});
Run Code Online (Sandbox Code Playgroud)
对象中是否有方法可以选择查看日期或类似方法?
这是我正在寻找的默认视图:
(如果这是重复的道歉 - 我看了但只发现了关于如何选择日期的问题.)
我试图找出在向数据库中插入一行时获取最后一个 ID 的最佳方法。
它是一个基本的库,它使用System.Data.SQLite
.
该库可以从控制台应用程序、表单应用程序、网站、服务、单线程、多线程调用 - 因此虽然这个库非常小且简单,但重要的是每次调用它都是无状态的、稳定的和准确的。
在我使用的主要 SQL 库中OUTPUT inserted.id
,这使事情变得非常简单,但据我所知,这在 SQLite 中不可用。我确实发现有一两个人提到了它,但它似乎对我不起作用。
如果没有,我看到另一种方法是创建一个游标并使用它来跟踪最后插入的 id。但是,它被列为扩展名,我似乎在 .NET 库中找不到任何迹象。
我能找到的最相关的 .NET 示例使用了让我担心的第二种命令方法。
我担心的是,当引发和记录异常时,通常会很快引发很多异常,我想 100% 确定我正确地链接了 InnerException 链。
INSERT INTO
...... OUTPUT inserted.id
SQLite 不支持?SELECT last_insert_rowid()
仅限于当前光标?GDI 是否有任何设置整体剪切区域的方法,就像 GDI+ Graphics 对象一样?
具体来说:
Graphics.DrawString
使用GDI+,其中包括剪切边界系统。TextRenderer.DrawText
使用GDI,但不使用GDI。我的新滚动条系统会Graphics
根据需要自动调整绘图区域的大小。在整理使用它的控件时,我将一些内联字符串渲染调用切换到我的文本布局类,该类使用TextRenderer.DrawText
. 我不太记得为什么我使用它而不是仅仅使用它Graphics.DrawString
,但在重构之前我想检查是否有某种方法可以解决问题。
public class GraphicsClipExample : Form
{
public GraphicsClipExample()
{
this.ClientSize = new Size(this.ClientSize.Width, 100);
}
protected override void OnPaint(PaintEventArgs e)
{
// update the graphics clip area
e.Graphics.Clear(Color.Cyan);
e.Graphics.SetClip(new Rectangle(0, 0, e.ClipRectangle.Width, 50));
e.Graphics.Clear(Color.Magenta);
Font font = new Font("Calibri", 24);
e.Graphics.DrawString("Testing", font, Brushes.Black, 10, 28);
TextRenderer.DrawText(e.Graphics, "Testing", font, new Point(150, 28), Color.Black);
}
}
Run Code Online (Sandbox Code Playgroud)
这会产生以下输出:
有没有办法为 …
c# ×3
.net ×1
css ×1
database ×1
datepicker ×1
gdi ×1
gdi+ ×1
graphics ×1
html ×1
inheritance ×1
jquery ×1
reflection ×1
sqlite ×1
types ×1
winforms ×1