小编Max*_*Max的帖子

将多个项目添加到同一行的列表框中

嘿伙计们,我想出了如何一次一行地将项目添加到列表框中:

try
{
     if (nameTxtbox.Text == "")
            throw new Exception();

     listBox1.Items.Add(nameTxtbox.Text);
     nameTxtbox.Text = "";
     textBox1.Text = "";
     nameTxtbox.Focus();
}
catch(Exception err)
{
     MessageBox.Show(err.Message, "Enter something into the txtbox", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Run Code Online (Sandbox Code Playgroud)

但我不能在同一行添加多个项目.喜欢有first_name | last_name | DoB都在同一条线上.当我做

listBox1.Items.Add(last_name.Text);
Run Code Online (Sandbox Code Playgroud)

它将姓氏添加到列表框中的新行,我需要将其添加到与第一个名称相同的行.

c# listbox winforms

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

使用Delegates的可访问性不一致

我试图发送一个stringform SettingsMenu使用到我的主要形式Delegate,如下图所示的结构:

在SettingsMenu表单中委派:

delegate void ClocknameReceivedEventHandler(object sender, SettingsMenu.ClocknameReceivedEventArgs e);
Run Code Online (Sandbox Code Playgroud)

SettingsMenu类中的内部类ClocknameReceivedEventArgs:

public partial class SettingsMenu : Form
{
    internal class ClocknameReceivedEventArgs : EventArgs
    {
        string _clockname;
        public string Clockname
        {
            get { return _clockname; }
        }

        public ClocknameReceivedEventArgs(string clockname)
        {
            _clockname = clockname;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在代码中更多一点SettingsMenu:

public event ClocknameReceivedEventHandler ClocknameReceived;

// Invoke the Changed event; called whenever list changes
protected void OnClocknameReceived(SettingsMenu.ClocknameReceivedEventArgs e)
{
    ClocknameReceived(this, e);
}
Run Code Online (Sandbox Code Playgroud)

SettingsMenuMain form使用以下内容捕获来自我的传入数据 …

c# delegates winforms

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

转换为字符串,删除一些部分并转换回byte []

我需要删除转换为字符串的byte []的前4个句子.

到目前为止我所拥有的:

//convert bytearray to string, so I can modify the string
string rawString = Convert.ToBase64String(rawByteArray);

//seperate lines
string[] textLines = Regex.Split(rawString, "\r\n");

//I need to substract the first 4 senctences of the string here!

//convert string back to byte array
byte[] cleanByteArray = rawstring.FromBase64String(rawString);
Run Code Online (Sandbox Code Playgroud)

如何减去前4个句子?

提前致谢!

c# string bytearray filter

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

在mysql中单个查询中更新两个表

我有两个名为supply和的表equipment.这两个表有一个名为的公共字段:IAR_NO

现在,我想要的是使用单个查询进行更新,两个表中包含0的所有记录IAR_NO.

什么可能是最好的查询?

我目前正在使用但不起作用

update supply, equipment 
set supply.IAR_NO =  "9", equipment.IAR_NO= "9 " 
where equipment.IAR_NO = 0 and supply.IAR_NO = 0
Run Code Online (Sandbox Code Playgroud)

mysql sql

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

C#中String的文件路径

我需要摆脱一个字符串驱动器,目录和扩展.虽然我经历的驱动器似乎无法让目录和扩展工作.

namespace ConsoleApplication1
{
    class GetMethods
    {
        public String GetDrive(String Path)
        {
            String Drive;
            Drive = Path.Substring(0, 2);
            Console.WriteLine("Drive: {0}", Drive);
            return Drive;
        }

        public String GetDirectory(String Path)
        {
            Console.WriteLine("Directorul: ");
            var start = Path.IndexOf(":") + 1;
            var match2 = Path.Substring(start, Path.IndexOf(".") - start);
            return Path;  
        }

        public String GetExtension(String Path)
        {
            String Extension;
            Extension = Path.Substring(0,3);
            Console.WriteLine("Extensia: {0}", Extension);
            return Extension;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            String Path;
            GetMethods G = new GetMethods();
            Console.WriteLine("Introduceti …
Run Code Online (Sandbox Code Playgroud)

c# string

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

如何判断Sysbase中的#table是否存在索引?

我在存储过程中使用Sybase 15 SQL.我想在临时#table上识别索引.常用技术适用于永久表,但不适用于临时表:

--look for an index on a temporary table

create table #T1( duff int)

create index idx99 on #T1(duff)

select * from sysindexes where name = 'idx99' --returns null rows !

--Look for an index on a permanent table

create table T1( duff int)

create index idx99 on T1(duff)

select * from sysindexes where name = 'idx99' --returns a row. OK for perm table.
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

短发

sql indexing sybase

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

无法将Int类型转换为List

我正在尝试在我的餐厅评论网站上创建一个功能,以确定餐厅是否已经过审核.如果餐厅未经审核,则返回变量.但是我一直收到错误Cannot implicitly convert type 'int' to 'System.Collections.Generic.List<>'就行了if (restaurantreview = 0).

任何帮助将不胜感激.

var restaurantreview = objCtx.Reviews.Where(r => r.RestaurantId == currentrestaurant).ToList();
if (restaurantreview = 0)
{
    var none = "Sorry Your Restaurant Hasnt been Reviewd Yet";
}
else
{
    var averagefood = objCtx.Reviews
                            .Where(r => r.RestaurantId == currentrestaurant)
                            .Average(r => r.Food);
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc if-statement

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

在C#中使用ForEach语句迭代两个数组

我有2个阵列

string[] Namesvalues = Names.Split(',');
string[] TotalValues = Total.Split(',');
Run Code Online (Sandbox Code Playgroud)

上面两个数组都有完全相等的值.我想要做的是并行迭代上面两个数组,并希望从两个数组中逐个获取值.

谁能告诉我怎么办?

c#

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

我应该声明我的字节[]

我正在检查我的应用程序"坏代码"使用ReSharper.

我有以下内容if-statement:

if (Utility.Compare(Utility.ExtractRangeFromArray(bufferRx, 0, bytesRead), new byte[] { U_EOT}))
{
   // EOT (End of transmission) received, break from while
   break;
}
Run Code Online (Sandbox Code Playgroud)

ReSharper告诉我改变:new byte[]new[]

我的问题:什么是最好的选择?为什么我不应该声明变量?

c# resharper declaration

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

如果在linq中检查条件

以下是linq查询.在这里,我想添加一个条件.条件:如果:Firstname不为空,则选择list where(d => d.firstname =="Firstname") else:选择所有列表无条件

function Ponits(string Firstname)
{

     pointsCore.Categories.SelectMany(c => c.Events).Select(e => new
     {
            e.Firstname,
            e.Surname,
            e.EntityNumber,
            e.Eventdate
     }).ToList()
}
Run Code Online (Sandbox Code Playgroud)

c# linq lambda

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