Quantcast
Channel: Visual C# forum
Viewing all 31927 articles
Browse latest View live

Seiko Smart Label Printer 620 (SLP 620) barcode size printing

$
0
0

We recently purchased a Seiko Smart Label Printer (SLP) 620 and it came with some sample SDKs for C#. I am trying to integrate label printing into my application without using their Smart Label Creator Software. Going through their sample SDK first off doesn't really provide any functioning code and their documentation is terrible. You can see the documentation for the SDK (Documentation), I tried calling their Support Number and they don't support their SDK at all.

Im trying to get the barcode to render at 18 point in Code128

I have this currently

private static void Code128BarCode()
        {
            SlpApi.SlpOpenPrinter("Smart Label Printer 620", SlpApi.Size_Shipping, false);

            if (SlpApi.SlpStartLabel())
            {

                SlpApi.SlpSetBarCodeStyle(SlpApi.SLP_BC_CODE128, 0, 0, 0, false, 12, 0, "");
                SlpApi.SlpDrawBarCode(1, 1, 400, 65, "CM_2157_1907834");

                SlpApi.SlpEndLabel();

                SlpApi.SlpClosePrinter();
            }
        }


C# code to do SFTP of files

$
0
0

Hi all

i don't know whether it's a right forum to ask this question.

I have to download files from my SFTP server into my local machine.

the code can be either VB.Net or C#.Net. please provide me the sample code.

let SFTP server be "TestWebServer", port 22, username and password, remote location "\" , local location "C:\test"

please help me.

 

Thanks

Sandeep

C# DllImport from C++

$
0
0

I am currently importing an C++ DLL into C# and the calls are working successfully. However, I am wondering if do I have to three imports to get use all 3 functions you below utilizing the same DLL? 

Is these necessary? If so, is the import creating an a new instance of the Dll for the each Dllimport?


pianoboyCoder


Display Cell Value Changes in DataGridView

$
0
0

I uppercase changes to values in the DataGridView. I even call Invalidate() to show the uppercase version of the value. The below code does not accomplish it. What do I need to do to make it work (ie: show the uppercase version of the cell)?

string edval = Cell.EditedFormattedValue.ToString().ToUpper();
string preval = Cell.Value.ToString();
if (preval == edval) return;
Cell.Value = edval;
dgv.Invalidate();


Jon Jacobs, There are 10 kinds of people: those who understand binary and those who don't

System.MissingMethodException however the method IS there...

$
0
0

I have a form application that is relatively simple at this point.

I have some methods like so:

        private void BugsGrid_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)
        {

                //Here I use the private class BFGridImageEditControl

        {

        private class BFGridImageEditControl : GridImageEditControl
        {
            public BFGridImageEditControl(
                ImageList imageList, ImageSizeMode sizeMode)
            {
                ImageList = imageList;
                ImageSizeMode = sizeMode;
            }
        }

However, even though the method is IN the form, I keep getting an error message that BFGridImageEditControl is not.  In fact, it worked all morning and then suddenly stopped, even though I wasn't even working on this area of the program.  Visual Studio simply lost the ability to see the method.

Is this a known bug?

I have cleaned and recompiled. I've removed the method and references to it, compiled, put the method back and recompiled.  I've deleted everything from the bin and obj folders and recompiled.

Nothing works.  Visual Studio simply can't see this method that is right there.  In fact, Intellisense even sees it...

This is really, really frustrating, particularly since the code would execute if Visual Studio would just run it. 

Has anyone else run into this problem?  Has anyone found a workaround to this bug?

Thanks for your help!


Error : must declare the scalar variable in C#

$
0
0

Must declare the scalar variable @code 

I tried with no dynamic query n its works , but when i tried to pass parameters send me that error , please help me 

Regards

public void Insert()
       {
           ReglaController re = new ReglaController();
           re.Regla_2();

           string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
           using (SqlConnection con = new SqlConnection(constr))
           {
               con.Open();

               string query = "INSERT INTO test (r1) VALUES (@code)";

               using (SqlCommand cmd = new SqlCommand(query, con))
               {
                   cmd.ExecuteNonQuery();


                  cmd.Parameters.Add("@code", SqlDbType.NVarChar).Value = re.Regla_2();



               }

           }

       }

How to find the offsets of a string in file

$
0
0

Hi guys,

I'm trying to search a large text file for a certain string and then ultimately replace that string with one of the same length, without making a whole new file. In order for me to write to the file in the most efficient way due to its size, I need some way of finding the offsets for every instance of a string within the file.

I saw a piece of code on this forum which finds the first occurrence, but because of my limitation in c# knowledge, I don't know how I could adapt this to find every occurrence.

This is the code:

public static string FindBytes(string fileName, byte[] bytes)
        {
            long i, j;
            using (FileStream fs = File.OpenRead(fileName))
            {
                for (i = 0; i < fs.Length - bytes.Length; i++)
                {
                    fs.Seek(i, SeekOrigin.Begin);
                    for (j = 0; j < bytes.Length; j++)
                        if (fs.ReadByte() != bytes[j]) break;
                    if (j == bytes.Length) break;
                }
            }
            return i;
        }

Any help would be appreciated. Thanks

C# Group by Sum

$
0
0

Hi

My database table example below

[Ratings %] is the column that i need to calculate and update.... 

A user can add a new movie from the front end so I'm looking to write a c# method to calculate the running percentage dynamically 

Formula= I need to group by Genres, then Movie ratings / Sum(Movie ratings)



Thanks for the help with pseudo code 


Howdy need a tip with visual studio

$
0
0
howdy, im trying to know how can i access to visual componets in c# already downloaded the free version of visual studio
im trying to make a windows form app, but i use to see buttons and text boxes and menus and those sort of drag componets.

Write Json To Excel

$
0
0

Dear experts

i use following code to write a Excel file from .json file

            string ofilepath = @"E:\temp\Gst2-error.json";
            OpenFileDialog fd = new OpenFileDialog();
            fd.FileName = @"E:\temp\Gst2-error.json";
            fd.Filter = "(*.json)|*.json";
            if (fd.ShowDialog() == DialogResult.OK)
            {
                ofilepath = Path.ChangeExtension(fd.FileName, "xls");
            }
            else
            {
                MessageBox.Show("Json File Not Selected");
                return;
            }
            if (!Directory.Exists(@"c:\gstreturns"))
            {
                Directory.CreateDirectory(@"c:\gstreturns");
            }

            using (FileStream s = File.Open(fd.FileName, FileMode.Open))
            using (StreamReader sr = new StreamReader(s))
            using (JsonReader reader = new JsonTextReader(sr))
            {
                JsonSerializer serializer = new JsonSerializer();
                GSTR1 o;
                while (reader.Read())
                {
                    if (reader.TokenType == JsonToken.StartObject)
                    {
                        //dynamic jr = serializer.Deserialize<dynamic>(reader);

                        o = serializer.Deserialize<GSTR1>(reader);

                        string swFileName = @"c:\gstreturns\" + GetUniqueName("b2b.csv", @"c:\gstreturns\");
                        StreamWriter sw = new StreamWriter(swFileName, cbIsAppend.Checked);

                        string monthyear = new DateTime(2018,Convert.ToInt16(o.fp.Substring(0, 2)), 1).ToString("MMM", CultureInfo.InvariantCulture);
                        monthyear += " " + o.fp.Substring(2);

                        #region b2b
                        string s1 = monthyear +"," + o.gstin,
                            s2 = "", s3 = "", s4 = "";
                        if (o.b2b != null)
                        {
                            b2bcsv(o, swFileName, sw, s1, ref s2, ref s3, ref s4);
                        }
                        #endregion b2b

                        if (o.cdn != null)
                        {
                            cdncsv(o, out swFileName, out sw, monthyear, out s1, out s2, out s3, out s4);
                        }

                        if (o.cdnr != null)
                        {
                            cdnrcsv(o, out swFileName, out sw, monthyear, out s1, out s2, out s3, out s4);
                        }
                    }
                }
            }

here i need first to create json class ( GSTR1) .

can i write excel without creating class dynamically as below. i am unable to think how i can do using following , can some body help me ?

dynamic jr = serializer.Deserialize<dynamic>(reader);



Send keystroke like OSK

$
0
0

Hello guys, how to send key stroke like on-screen keyboard does?

Any guide or example to begin with.

Thank you.


Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.

[Windows Security] pop-up lost focus - CredUIPromptForWindowsCredentials

$
0
0

Dear All

I have small program access to Shared Folder on another PC, my PC and Shared's PC have different domain.
My program have [Check access] button, i will using this button to check connect success or not. If connection need permission to access to shared folder, [Windows Security] pop-up is displayed.
In my source code, i using CredUIPromptForWindowsCredentials to create [Windows Security] pop-up.

I have tested on my PC, all are so good, all are working so good.
But when i move my program to another PC (Window 10 - Customize by turn-off some API, Services, etc ... I call this PC is PCBugs). Bug is occurs.

Bug is:
- When I click to [Check access] button by mouse, [Windows Security] pop-up is freeze, i can't input to [Windows Security], can't move, can't close, do nothing ...
- When I click to [Check access] button by Enter key, [Windows Security] pop-up is ok, i cant input to [Windows Security], can move, can close, do anything ...

I have investigated and found something. I have set "Handle" of Parent form to pUiInfo.hwndParent parameter.
"Handle" have some trouble on PCBugs , i don't know why, on my PC (Dev PC), it work ok.

To fix this bug: I don't set "Handle" of Parent form to pUiInfo.hwndParent parameter (If the hwndParent member of the CREDUI_INFO structure is NULL, the function displays a dialog box centered on the screen.). Bug is fixed.

But is not my expected, I think on PCBugs, something is turn-off, or something different between PCBugs and Dev PC. I think best way is config environment on PCBugs.

Please give me some suggestion!


Implementing ItsPubPlugin in C#

$
0
0

I'm trying to extend my RDWeb environment to include user's personal desktops (non-virtual) as a RemoteApp icon.  Currently we manually generate .rdp files for end-users to connect through an RDGateway to their office computer depending on their location (each physical location has their own RDGateway).

Came across this post http://technet.microsoft.com/en-us/library/dd883277(v=ws.10).aspx.  Looks like options are implement Personal Virtual Desktops with VDI or build a plugin for RDWeb that would return a .rdp file as a "RemoteApp".

http://blogs.msdn.com/b/rds/archive/2009/11/11/remoteapp-and-desktop-connection-management-extensibility-for-provisioning-apps-via-rd-web-access.aspx talks about how things work and what interface to use for my plugin.

http://msdn.microsoft.com/en-us/library/dd401684(v=vs.85).aspx is the interface I want to implement in C#.  The IDL file listed "Cpubplugin.idl" does not exist on my 2008r2 or 2012 RDWeb servers.

Here are some other links that could be applicable:

http://stackoverflow.com/questions/1307675/convert-interface-idl-file-to-c-sharp

http://msdn.microsoft.com/en-us/library/x8fbsf00.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/aa367062(v=vs.85).aspx

So, down to the question:

How can I implement an interface that I don't have an IDL file for?

Sample code would be most appreciated as I'm only a part-time programmer - but of course any help would be appreciated.

Thank you

-Andrew

Task.Yield Method

$
0
0

I checked the description of the document:
Creates an awaitable task that asynchronously yields back to the current context when awaited.

Does it mean that await task.Yield is equivalent to this.begininvoke in winform program.

I saw people saying that
1.Task.Yield has a notification thread to do other things
2.Task.Yield gives up the function of the current thread
Are these two statements wrong?
I think
The role of await Task.Yield is equivalent to BeginInvoke in winform


please verify my account

WPF - Videos

$
0
0

Morning all,

I'm new to these forums so I'm hoping you can help me please.

I've recently started working with C# in Visual Studio to build an application. I've got the majoirty of it in place however, I would like to embed a YouTube video into one of the pages. I'm hoping for it to automatically display to fill the screen of my WebBrowser box in the WPF page. 

I've seen online about using WindowsForms but I was hoping to embed a video in WPF. 

Is this possible at all?

Thanks,

Andy


Convert PDF to doc /word

$
0
0

Hi All,

 

How to convert PDF file to Word document? using c#

After conversion word document should be editable.

 

Is there any ready made software available?(After conversion word document should be editable)

 

Thanks

Ashok

how to change from TLS 1.1 to 1.2

$
0
0

i have .net application written in .net 4.0 and have win 2008 R2 server.

need to change from TLS from 1.1 to 1.2.

how can i change?

do i need to change the .net framework to 4.5 to support TLS 1.2 or do i need to change anything on the win 2008R2 side?

any help would be greatly appreciated.


its very urgent.

Regards,

Yogi


yogi

Unexpected token append

$
0
0

I wrote a simple language translator application using IronPython and I call the python code via a C# console application. I tested the python code separately and it works fine. However, when I call the python code via the C# application it always gives the Microsoft.Scripting.SyntaxErrorException: 'unexpected token 'append'' error message.

ScriptEngine engine =Python.CreateEngine();ScriptSource source = engine.CreateScriptSourceFromFile(@"D:\Projects\Translator.py");ICollection<string>Paths= engine.GetSearchPaths();Paths.Add(@"C:\Program Files\Python37\Lib\");
Paths.Add(@"C:\Program Files\Python37\Lib\site-packages\");
engine.SetSearchPaths(Paths);ScriptScope scope = engine.CreateScope();
source.Execute(scope);dynamicGoogleTranslator= scope.GetVariable("GoogleTranslator");dynamic gTranslator =GoogleTranslator();
gTranslator.SetInfo("'Привет, корова мальчик'");var result = gTranslator.Translate();Console.Write(result.text);Console.Read();

Can anyone tell me what is the issue with the code. The error generate from the "source.Execute(scope);"


Gehan Fernando Snr. Engineer Technology. AKLO Information Technologies (Pvt) Ltd. #58, 42nd Lane, 5th Floor, Wellawatta, Colombo 06, Sri Lanka. Phone: +94 117 520000 | Mobile: +94 772 269625



How to import embedded exe and execute it ?

$
0
0
Hello everybody,
I am new to c#, and i am making some simple application.
I am using Visual Studio 2008 - windows form app


I want to be able to include other exe to my project - embedded for example (Add Existing File -> .exe) and run it on some event.

I found out how to embed picture files - and show them like stream -
i want to be able to do something like that with exe file.

I dont want the embedded exe to run inside of my application - i want it to run outside of my app when i press some button in the main application for example.

any help will be great :)

thank you for you attention :)

Saving a memory Game in C#

$
0
0

Hello,

Who can help me to save a Memory Game in C#?

I need to save the game with a button but i cant figure it out how ..

Kind Regards.

Viewing all 31927 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>