小编Med*_*000的帖子

动态工具提示取决于数据网格中的行上的鼠标(NOT datagridview)

我试图让它成为当用户将鼠标悬停在我的DataGrid/dataview中的一行时,每一行都会显示不同的工具提示结果.

我无法弄清楚这一点.使用DataGrid我怎么能说每行上的mouseOver并给出行特定的数据?似乎所有我平常的在线资源都没有发现!

如果有一种方法可以使用datagridview,我不知道如何填充它(datagridview),因为每次程序运行时我的表的长度都不一样.(程序跟踪信号,所以如果收到更多信号,那么表格会有更多行...)

*注意:这是视觉工作室2005环境中的视觉C#2.0.

*结束了以下:

private void datagridSignal_MouseMove(object sender, MouseEventArgs e)
{
        this.toolTip.Hide(datagridSignal);
        this.toolTip.RemoveAll();
        DataTable dt = GetSignalTable();
        DataView dv = new DataView(dt);
        Point prop = new Point(e.X, e.Y);
        System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
        prop = datagridSignal.PointToClient(prop);
        myHitTest = datagridSignal.HitTest(prop.X, prop.Y);
        this.toolTip.SetToolTip(datagridSignal, " ID = '" + (int)dv[myHitTest.Row][0] + "' ");
}
Run Code Online (Sandbox Code Playgroud)

c# dataview datagrid tooltip winforms

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

C#:读取XML属性

使用C#2.0和VIsualStudio2005

我正在尝试从一个XML文件中访问"MonitorResponseRecord"中的"DisplayName",如下所示:

    <Magellan xsi:schemaLocation="http://tempuri.org/XMLSchema.xsd ..\Schema\Configuration.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
      <SchemaVersion>1.0</SchemaVersion>
          <MonitorScope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="CleanStationChemicalManifoldFeed5" xmlns="http://tempuri.org/XMLSchema.xsd">
            <PersonalSafety>
              <MonitorResponseRecord Enabled="true" DisplayName="ChemicalManifoldFeed5ControllerFault">
                <ExpressionMonitor>
                  <Expression>(ChemicalManifold.Feed5.DispenseValve = Open) and ((ChemicalManifold.Feed5.ViolatedRegion = HighProcess) or (ChemicalManifold.Feed5.ViolatedRegion = LowProcess) or (ChemicalManifold.Feed5.ViolatedRegion = Minimum))</Expression>
                  <TestInterval>0.1</TestInterval>
                  <MinimumTimeBetweenResponses>5</MinimumTimeBetweenResponses>
                </ExpressionMonitor>
                <Response>
                  <PostAlarm>
                    <AlarmName>ChemicalManifold_Feed5_ControllerFault</AlarmName>
                    <Parameter1 />
                    <Parameter2>Alarm Region = {ChemicalManifold.Feed5.ViolatedRegion}</Parameter2>
                    <Parameter3>{RecipeName}-{StepName}</Parameter3>
                    <Parameter4>FlowSetpoint = {ChemicalManifold.Feed5.Setpoint}-LPM, ActualFlow = {ChemicalManifold.Feed5.FlowMeter}-LPM</Parameter4>
                  </PostAlarm>
                  <ResponseEvent>
                    <TargetResource />
                    <Event>PA</Event>
                    <Reason>ChemicalSupply</Reason>
                  </ResponseEvent>
                </Response>
              </MonitorResponseRecord>
            </PersonalSafety>
            <PersonalSafety>
              <MonitorResponseRecord Enabled="true" DisplayName = "PressureValveFailure">
           ...
            ...                
             ...and soon
Run Code Online (Sandbox Code Playgroud)

我目前的C#尝试如下,但是当我尝试时它总是挂起 XmlDocument.Load("");

                XmlDocument doc = new XmlDocument();
                doc.Load("../UMC0009.Configuration.Root.xml"); …
Run Code Online (Sandbox Code Playgroud)

c# xml visual-studio-2005 c#-2.0

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

更加"智能"地阅读文本文件

我有一个文本文件,其中包含按字母顺序排列的变量列表,其变量编号旁边的格式如下:

aabcdef           208
abcdefghijk       1191
bcdefga           7
cdefgab           12
defgab            100
efgabcd           999
fgabc             86
gabcdef           9
h                 11
ijk               80
...
...
Run Code Online (Sandbox Code Playgroud)

我想将每个文本作为字符串读取并保持其指定的id#,如read"aabcdef",并将其存储在208的数组中.

我遇到的两个问题是:

  1. 我从来没有在C#中读过文件,是否有一种方法可以读取,从行首开始到空格作为字符串?然后将下一个字符串作为int直到行尾?

  2. 鉴于这些文件的性质和大小,我不知道每个文件的最高ID值(并非所有数字都被使用,所以有些文件可能包含3000个数字,但实际上只列出200个变量)所以我怎样才能灵活地进行当我不知道数组/列表/堆栈/等等需要多大时,存储这些变量.

c# arrays sorting file-io input

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

C#4.0使用winmm.dll播放超过192kbps的.mp3文件

MCIERR_INTERNALI我正在尝试在应用程序中制作一个简单的媒体播放器,但我注意到我的代码不会播放音乐,除非该文件的比特率低于192kbps或更低.问题是我的大部分音乐都在260-320kbps左右.

这是我的代码,如果有什么我可以做的'可用'比特率选项让我知道,否则我需要一个新的DLL建议!

class MusicPlayer
{
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);

    private static void checkMCIResult(long code)
    {
        int err = (int)(code & 0xffffffff);
        if (err != 0)
        {
            throw new Exception(string.Format("MCI error {0}", err));
        }
    }

    public void open(string file)
    {
        string command = "open \"" + file + "\" type MPEGVideo alias MyMp3";
        checkMCIResult(mciSendString(command, null, 0, 0));
    }

    public void play()
    {
        string command = "play MyMp3";
        mciSendString(command, null, 0, 0);
    } …
Run Code Online (Sandbox Code Playgroud)

c# audio mp3 winmm

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

C++生成0到100,000之间的随机数

做这个的最好方式是什么?我的编译器显示RAND_MAX = 32,767.所以我很好奇如何获得0到100,000之间的均匀随机生成值?

c++ random solaris g++

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

替换所有程序的Windows快捷方式

是否有可能让我的覆盖优先于系统范围,所以即使在运行Web浏览器,文字编辑器或绘图程序时(我的应用程序仍将在后台运行或显然是作为服务运行)

使用Visual C#2010

我如何覆盖我的代码的示例:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 
{
    if((keyData == (Keys.Control | Keys.C))
    {
         //your implementation
         return true;
    } 
    else if((keyData == (Keys.Control | Keys.V))
    {
         //your implementation
         return true;
    } 
    else 
    {
        return base.ProcessCmdKey(ref msg, keyData);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# service hotkeys

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

如何在字符的第一个实例处截断字符串?

我目前有一个字符串1_0707201206050239,我想截断右边的所有字符,包括_char.

问题是左侧的字符因用户输入而异,因此字符串的长度始终不同.右侧_表示日期和时间(例如07-07-2012 6:05:02.390AM)长度可以在17-14个字符之间变化.

所以我想知道在_检测到之前是否有截断的方法?

.net c# string

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

在.NET/C#2.0中合并两个字符串数组?

可能重复:
在.NET中合并两个数组
如何在C#中连接两个数组?

我怎么能合并两个string[]变量?

例:

string[] x = new string[] { "apple", "soup", "wizard" };
string[] y = new string[] { Q.displayName, Q.ID.toString(), "no more cheese" };
Run Code Online (Sandbox Code Playgroud)

我想添加这两个,所以内容x是:{"apple", "soup", "wizard",Q.displayName, Q.ID.toString(), "no more cheese"};按顺序.这可能吗?如果结果必须进入一个很好的新字符串数组; 我只是想知道如何实现它.

.net c# arrays string c#-2.0

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

在WCF服务中"检测到无法访问的代码"

这个问题与本问题直接相关,但我认为因为主题不同我会为当前问题开始一个新问题.我有一个WCF服务,一个服务和一个GUI.GUI将一个int传递给WCF,该WCF应该将其存入List<int> IntList; 然后在服务中我想访问列表.问题是,当我尝试添加到WCF服务中的列表时,我收到"检测到无法访问的代码"警告,并且当我通过它进行调试时,添加行被完全跳过.如何让这个列表"可以访问"?

下面是WCF代码,对WCF的GUI调用以及使用List<>from WCF 的服务:

WCF:

[ServiceContract(Namespace = "http://CalcRAService")]
public interface ICalculator
{
    [OperationContract]
    int Add(int n1, int n2);
    [OperationContract]
    List<int> GetAllNumbers();
}

// Implement the ICalculator service contract in a service class.
public class CalculatorService : ICalculator
{
    public List<int> m_myValues = new List<int>();

    // Implement the ICalculator methods.
    public int Add(int n1,int n2)
    {
        int result = n1 + n2;
        return result;
        m_myValues.Add(result);
    }
    public List<int> GetAllNumbers()
    {
        return m_myValues;
    } …
Run Code Online (Sandbox Code Playgroud)

c# service wcf windows-services

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

如何从smalltalk中的字符串中删除前导字符

所以我在一个小谈话中有一个字符串,该字符串作为'$ 100xxxxxxZZ'来到TCP/IP连接,其中x是数字0-9或字母A-Z,ZZ是由发送者计算的校验和.使用字符串我需要计算'100xxxxxx'的校验和,以验证这是正确的消息和校验和.所以我需要能够删除'$ 100xxxxxxZZ'的'$'和'ZZ'

我已经知道如何截断'ZZ',这是我的代码:

ValidateMsg:replyWithCheckSum

|newMsg tempMsg|
"removes the 'ZZ' from '$100xxxxxxZZ'  "
tempMsg := replyWithCheckSum copyFrom: 2 to: (replyWithCheckSum size -2).

"CODE TO REMOVE THE '$' AND STORE INTO newMsg"

"compares the 'ZZ' to the checksum calculated from newMsg"
^(self calcCheckSum: newMsg) = (self getCheckSumFromReply: replyWithCheckSum)
Run Code Online (Sandbox Code Playgroud)

TL; DR如何在visualt 2.5中删除smalltalk中字符串中的第一个字符(是的,我知道这很古老)

string smalltalk visualworks truncation

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

用C#读取一个简单的XML配置文件

我很难记住如何执行此操作,我看到的大多数示例并未真正涵盖我的问题。我试图读取下面的XML文件,以便如果用户从下拉菜单中选择“工具类型”,则该工具的变量将填充屏幕上的表格。我只是不知道如何收集特定工具的所有元素/属性。

<?xml version="1.0" encoding="UTF-8"?> 
<Tool_menu>
    <tool name="A">
        <emails>
            <email severity="Low">
                <address>reg@test.com</address>
            </email>
            <email severity="High">
                <address>notReg@test.com</address>
            </email>
        </emails>
        <configuration_list>
            <configuration>
                <name>Confg1</name>
            </configuration>
            <configuration>
                <name>Confg2</name>
            </configuration>
            <configuration>
                <name>Confg3</name>
            </configuration>
            <configuration>
                <name>Confg4</name>
            </configuration>
        </configuration_list>
    </tool>
    <tool name="B">
        <emails>
            <email severity="Low">
                <address>reg@test.com</address>
            </email>
            <email severity="High">
                <address>notReg@test.com</address>
            </email>
        </emails>
        <configuration_list>
            <configuration>
                <name>n/a</name>
            </configuration>
            <configuration>
                <name>n/a</name>
            </configuration>
        </configuration_list>
    </tool>
    <tool name="C">
        <emails>
            <email severity="Low">
                <address>reg@test.com</address>
            </email>
            <email severity="High">
                <address>notReg@test.com</address>
            </email>
        </emails>
        <configuration_list>
            <configuration>
                <name>200Scope</name>
            </configuration>
            <configuration>
                <name>300Scope</name>
            </configuration>
            <configuration>
                <name>600Scope</name>
            </configuration>
            <configuration>
                <name>900Scope</name>
            </configuration>
        </configuration_list>
    </tool> …
Run Code Online (Sandbox Code Playgroud)

.net c# xml visual-studio

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

将ListViewItem分配给组?

{
    Profile p=new Profile("Name","Var1","Var2",True,False,110102);
    ...
    ...
    if(true)
    {
       var item = new ListViewItem{Text = p.Name, Tag = p};
       ListView1.Items.Add(item);
       ListView2.Items.Add((ListViewItem)item.Clone());
    }
}
Run Code Online (Sandbox Code Playgroud)

我在ListView中声明了2个组,我将它们添加到visual studio的Designer中的groups集合中.这些组是"过期的配置文件"和"活动配置文件"我的问题是,当我添加到ListView时,如何将这些项目分配到组中?我希望所有个人资料都能自动进入列表视图"活动资料"分组

c# listview listviewitem

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

如何在写入CSV文件时格式化文本

我有一大堆代码负责编写.CSV文件,但格式化很可怕.我想知道是否有一个命令或字符串我可以发送到CSV以表示它应该为所有单元格加粗第一行文本和中心文本.这可能吗?

 StreamWriter sw = null;
 try
 {
     this.SetStatus(DataLogUIStrings.strSavingToCSVFile);
     sw = new StreamWriter(exportFileName, this.appendExport);
     //first row of CSV
     sw.WriteLine("Start Time,End Time,Date,JobID,,Alarm Count");
     foreach (SJob job in jobsToExport)
     {
         //rest of CSV rows
         sw.WriteLine(job.GetJobInformation().Replace(',', '\t'));
     }
     this.SetStatus(string.Format(DataLogUIStrings.strJobsExported, jobsToExport.Count));
 }
 catch
 {
  ...
 }
Run Code Online (Sandbox Code Playgroud)

我的搜索没有得到任何东西,我希望有一些excel公式命令所以字符串可能只是"BOLD(Start Time,End Time,...)";如果不让我知道任何替代品可以完成这个没有打开excel表和手动格式化(作为软件产生周围每天24小时)

c# csv excel visual-studio-2010

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