小编Pil*_*anz的帖子

在div内部设置div以滚动,而父级不滚动

我有一个容器div,它拥有许多子div.我容器中的一个div有评论.我没有将整个div设置为滚动,而是希望所有内容保持原位,只留下注释div滚动.我已经尝试将父溢出设置为隐藏,并将注释div设置为滚动,并且滚动条实际显示在页面上但它被禁用.有谁知道我怎么能做到这一点?

CSS

#container
{                
   position: absolute; 
   overflow: hidden; 
}

#comments
{
   position: relative;
   overflow: scroll; 
}
Run Code Online (Sandbox Code Playgroud)

HTML

<div id="container">
   <div id="comments">
      this is what I want to scroll
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我无法摆脱容器,因为它包含更多的子元素.我只是希望其他所有内容保持静态,而只有注释可以滚动.

html scroll

33
推荐指数
2
解决办法
5万
查看次数

使用Excel Interop删除空行

我有用户提供的需要转换为PDF的excel文件.使用excel互操作,我可以做到这一点.ExportAsFixedFormat().当工作簿有数百万行时,我的问题出现了.这将变成一个有50k +页面的文件.如果工作簿在所有这些行中都有内容,那就没问题.每次出现其中一个文件时,可能有50行有内容,其余的都是空白.我怎样才能删除空行,以便将其导出为合适大小的PDF?

  1. 我已经尝试从最后一行开始,一个接一个,CountA用来检查行是否有内容,如果有,则删除它.这不仅需要永远,这似乎在大约100k行后失败,并出现以下错误:

    无法计算表达式,因为代码已优化或本机帧位于调用堆栈之上.

  2. 我尝试过使用SpecialCells(XlCellType.xlCellTypeLastCell, XlSpecialCellsValue.xlTextValues)但如果任何单元格有格式(如bg颜色),则包含一行.

  3. 我尝试过使用Worksheet.UsedRange然后删除所有内容,但UsedRange与第二点有同样的问题.


这是我试过的代码:

for (int i = 0; i < worksheets.Count; i++)
{
    sheet = worksheets[i + 1];
    rows = sheet.Rows;
    currentRowIndex = rows.Count;
    bool contentFound = false;

    while (!contentFound && currentRowIndex > 0)
    {
        currentRow = rows[currentRowIndex];

        if (Application.WorksheetFunction.CountA(currentRow) == 0)
        {
            currentRow.Delete();
        }
        else
        {
            contentFound = true;
        }

        Marshal.FinalReleaseComObject(currentRow);
        currentRowIndex--;
    }

    Marshal.FinalReleaseComObject(rows);
    Marshal.FinalReleaseComObject(sheet);
}
Run Code Online (Sandbox Code Playgroud)
for (int i = 0; i < worksheets.Count; …
Run Code Online (Sandbox Code Playgroud)

c# office-interop excel-interop

14
推荐指数
1
解决办法
1万
查看次数

如何使用C#语言在数据库中插入记录?

我只是C#的初学者,所以我需要太多的帮助.现在的问题是我设计了一个窗口表单,其中有许多字段,如名字,姓氏,地址等.现在我想要做的是,当我填写表单并单击插入按钮时,所有信息都进入数据库.有谁知道这是怎么做到的吗?

private void button1_Click(object sender, System.EventArgs e)
{
    string connetionString = null;
    SqlConnection cnn ;
    SqlDataAdapter adapter = new SqlDataAdapter();
    string sql = null;
    connetionString = "Data Source=UMAIR;Initial Catalog=Air; Trusted_Connection=True;" ;

    cnn = new SqlConnection(connetionString);
    sql = "insert into Main (Firt Name, Last Name) values(textbox2.Text,textbox3.Text)";

    try
    {
        cnn.Open();
        adapter.InsertCommand = new SqlCommand(sql, cnn);
        adapter.InsertCommand.ExecuteNonQuery();
         MessageBox.Show ("Row inserted !! ");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}
Run Code Online (Sandbox Code Playgroud)

c# database visual-studio-2008

9
推荐指数
4
解决办法
10万
查看次数

AutoMapper - 一对多映射

我在将一个带有嵌套列表的源对象映射到多个目标对象时遇到问题。由于项目限制,我只能修改部分代码。我正在使用 AutoMapper 5.1。

/// no changes possible
namespace Source
{
    class Person
    {
        public string Name { get; set; }
        public List<Car> Cars { get; set; }

        public Person()
        {
            Cars = new List<Car>();
        }
    }

    class Car
    {
        public string NumberPlate { get; set; }
    }
}

/// no changes possible
namespace Destination
{
    class PersonCar
    {
        public string Name { get; set; }
        public string NumberPlate { get; set; }
    }
}

/// Demo Consolen Application …
Run Code Online (Sandbox Code Playgroud)

c# automapper

7
推荐指数
1
解决办法
6482
查看次数

以CSV格式显示逗号而不使用逗号字符

我有一个CSV格式日志,我们写了一些日志记录操作.但是,其中一个字段允许用户输入,我需要确保如果他们在字段中输入我们解析它的逗号并将其替换为某些东西,例如,Excel将能够读取并在其中显示逗号放置(因此csv读者不会认为它是列的结尾).

目前我替换了逗号,&#44;但这在Excel中显示为文字字符串.

是否有标准方法在不使用实际逗号字符的情况下在CSV文件中显示逗号?即使只适用于excel的解决方案也可以使用,因为我们的大多数客户都将使用Excel来查看此文件.

c# csv character-replacement

6
推荐指数
1
解决办法
9859
查看次数

在转发器控件中使用复选框

我从昨天起就一直试图这样做,但想不到解决方案.我有一个包含复选框和文件上载的转发器,这个转发器根据我的表的内容重复多次.选中文件上传下方的复选框时,它不应检查文件上载量.我想不出有什么方法可以做到这一点.有任何想法吗?继承人的代码.

班级:

protected void UploadButton_Click(object sender, EventArgs e)
{
    String savePath = @"~/files/";
    try
    {
        foreach (RepeaterItem item in rptVrijstellingen.Items)
        {               
            FileUpload file=(FileUpload)item.FindControl("FileUpload1");
            HiddenField uid = (HiddenField)item.FindControl("hiddenid");
            CheckBox ch = (CheckBox)item.FindControl("CBupload");
            if(ch.Checked)
                Response.Write("checked");
            else
            {
                if (file.HasFile)
                {
                  String fileName = file.FileName;
                  savePath += fileName;
                  file.SaveAs(Server.MapPath(savePath + fileName));
                  tblBijlage s = new tblBijlage();
                  s.bijlageTitel = fileName;
                  s.bijlageURL = savePath;
                  s.bijlageType = "1";
                  s.fk_externvakID = Convert.ToInt16(uid.Value);
                  BLLstudent.insertFile(s);
                }
                else
                  throw new Exception("Gelieve bij alle vakken een file toe te voegen of …
Run Code Online (Sandbox Code Playgroud)

c# asp.net repeater

5
推荐指数
1
解决办法
3008
查看次数

如何在悬停后将鼠标移出动画

这正是我想要实现的目标(当我悬停时动画开始并在我悬停后启动).我只是不希望动画开始,直到我将鼠标悬停在对象上.在代码中,动画在刷新后立即启动.

.class {
  animation-name: out;
  animation-duration: 2s;
  /* Safari and Chrome: */
  -webkit-animation-name: out;
  -webkit-animation-duration: 2s;
}
.class:hover {
  animation-name: in;
  animation-duration: 5s;
  animation-iteration-count: infinite;
  animation-direction: normal;
  /* Safari and Chrome: */
  -webkit-animation-name: in;
  -webkit-animation-duration: 5s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-direction: alternate;
}
@keyframes in {
  from {
    transform: rotate(50deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@-webkit-keyframes in
/* Safari and Chrome */

{
  from {
    transform: rotate(50deg);
  }
  to {
    -webkit-transform: rotate(360deg);
  }
}
@keyframes out {
  from {
    transform: …
Run Code Online (Sandbox Code Playgroud)

javascript css css3 css-animations

5
推荐指数
1
解决办法
3892
查看次数

将字符串传递给$

尝试通过Code School CoffeeScript课程来掌握CoffeeScriptjQuery.

其中一个摘录是$("<li>" + name + "</li>").我设法弄清楚这$jQuery(右边?)的别名,所以我猜这意味着我们用字符串调用jQuery函数(name是一个字符串,由两个文字包围).

那么......这个jQuery功能本身有什么作用?试着看着api.jquery.com,很难搞清楚.谢谢!

jquery

3
推荐指数
1
解决办法
812
查看次数

执行GZipStream压缩时抛出System.OutofMemoryException

我正在以胜利的形式工作.执行以下操作时出错.System.OutOfMemoryException当我尝试连续2-3次运行操作时,它显示错误.似乎.NET无法释放运行中使用的资源.我用于操作的文件非常大,大约超过500 MB.

我的示例代码如下.请帮我解决错误.

try
{
   using (FileStream target = new FileStream(strCompressedFileName, FileMode.Create, FileAccess.Write))
   using (GZipStream alg = new GZipStream(target, CompressionMode.Compress))
   {
       byte[] data = File.ReadAllBytes(strFileToBeCompressed);
       alg.Write(data, 0, data.Length);
       alg.Flush();
       data = null;
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)

.net c# out-of-memory gzipstream

2
推荐指数
2
解决办法
2619
查看次数

对DataGridViewImage列进行排序

我需要能够DataGridViewImageColumn通过点击它的标题来排序.我在设计器中将排序模式设置为自动,但是当我点击标题时没有任何反应.

这些列是可排序的吗?

如果是这样,我需要做什么?

谢谢!

vb.net datagridview

2
推荐指数
1
解决办法
2691
查看次数

SaveFileDialog事件FileOk

private void button2_Click(object sender, EventArgs e)
{        
    SaveFileDialog Sdialog = new SaveFileDialog();  
    Sdialog.ShowDialog();
    Sdialog.FileOk += Sdialog_FileOk;            
}

void Sdialog_FileOk(object sender, CancelEventArgs e)
{
    try
    {            
        StreamWriter FileProtocol = new StreamWriter(((SaveFileDialog)sender).FileName);
        FileProtocol.Write(textBox3.Text);
        FileProtocol.Close();
        MessageBox.Show("File is write ok");
    }
    catch (Exception)
    {
        MessageBox.Show("Unknown Error. File is not write");
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么事件FileOk不起作用?

.net c# winforms

2
推荐指数
1
解决办法
3741
查看次数

在表单中声明C#类对象

可以放在"view = new Person"按钮事件处理程序中吗?如果我不这样做,并将其放在Form1构造函数中,则只添加我的最后一个值.如果我想声明一个新实例然后将其添加到我的Arraylist中,这是正确的方法吗?

    private ArrayList store;

    public Form1()
    {
        InitializeComponent();
        store = new ArrayList();
    }

    private void Form1_Load(object sender, EventArgs e)
    { }

    private void button1_Click(object sender, EventArgs e)
    {
        //Is it okay to declare a new instance of the Person class 
        // with each button push?            
        Person view = new Person();
        view.firstname = txtFirstName.Text;
        view.lastname = txtLastName.Text;
        store.Add(view);
        txtFirstName.Clear();
        txtLastName.Clear();   
    }

    private void button2_Click(object sender, EventArgs e)
    {
        foreach (Person display in store)
        {
            MessageBox.Show(display.ToString());
        } …
Run Code Online (Sandbox Code Playgroud)

c# forms collections visual-studio

1
推荐指数
1
解决办法
792
查看次数

撤消下拉列表的默认顺序

有没有一种简单的方法来反转下拉列表的默认顺序?

if (_group.Category == GroupCategory.Workers || 
    _group.Category == GroupCategory.Acct)
{
      this.cboList.DataSource = null;
      this.cboList.DisplayMember = "DescForMCE";
      this.cboList.ValueMember = "ID";
      this.cboList.DataSource = _ch.Accounts;
      this.cboList.Visible = true;
      this.lblList.Visible = true;
}
Run Code Online (Sandbox Code Playgroud)

c# dropdownbox

1
推荐指数
1
解决办法
1182
查看次数