|
by using c# code how to transfer the entire english windows form into arabic language
|
|
|
|
|
look up satellite assemblies...
basically you define "resources" which is a table with key/value pairs. You have one for each language.
|
|
|
|
|
Hi I am binding data of same table in two different data grid view in the same form. It includes removing and filtering of the rows.
There are two biding source for the two dgv. But it sometimes it shows some weird behaviours on the data.
Can you explain what possible goes wrong.
|
|
|
|
|
Member 11431015 wrote: But it sometimes it shows some weird behaviours Please do not assume that people can guess what that means.
|
|
|
|
|
Hi, I have the following code for pressing a button in windows forms. Don`t be scared by long code, I have declared some vars and I have 2 query there. One for get first results and second is like a pagination. The problem is if I press first time on button I get some results, but if I press second time I don`t get the next results but the same. How can I change the code so if I press multiple times to get next and next results.
string defaultImage;
string lang = "en";
string selectedLang = comboBox1.SelectedItem.ToString();
int Count = 5;
int maxStatuses = Convert.ToInt32(numericUpDown3.Value);
var statusList = new List();
int lastStatusCount = 0;
switch (selectedLang)
{
case "English":
lang = "en";
break;
case "Romanian":
lang = "ro";
break;
case "Italian":
lang = "it";
break;
case "French":
lang = "fr";
break;
default:
lang = "en";
break;
}
var auth = apiConnect();
var twitterCtx = new TwitterContext(auth);
var searchResponse =
await
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == q &&
search.Count == Count &&
search.SinceID == sinceID &&
search.SearchLanguage == lang &&
search.ResultType == ResultType.Recent
select search)
.SingleOrDefaultAsync();
if (searchResponse != null && searchResponse.Statuses != null)
{
List newStatuses = searchResponse.Statuses;
maxIDlim = newStatuses.Min(status => status.StatusID) - 1;
statusList.AddRange(newStatuses);
do
{
label19.Text = maxIDlim.ToString();
searchResponse =
await
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == q &&
search.Count == Count &&
search.SinceID == sinceID &&
search.MaxID == maxIDlim &&
search.SearchLanguage == lang &&
search.ResultType == ResultType.Recent
select search)
.SingleOrDefaultAsync();
newStatuses = searchResponse.Statuses;
maxIDlim = newStatuses.Min(status => status.StatusID) - 1;
statusList.AddRange(newStatuses);
lastStatusCount = newStatuses.Count;
label18.Text = maxIDlim.ToString();
} while (lastStatusCount != 0 && statusList.Count < maxStatuses);
listView1.BeginUpdate();
for (int i = 0; i < statusList.Count; i++)
{
Status search = statusList[i];
if (search.User.DefaultProfileImage)
defaultImage = "NO";
else
defaultImage = "YES";
string[] row = { search.User.ScreenNameResponse, search.Text, defaultImage, search.StatusID.ToString() };
var listViewItem = new ListViewItem(row);
listView1.Items.Add(listViewItem);
}
listView1.EndUpdate();
}
|
|
|
|
|
Press a button on what? Some of your code appears to perhaps be ASP.NET related, which if that is the case then you should post your question to the specific ASP-NET Discussion Board[^] as you will get a better answer. The C# Discussion board is generally for basic questions pertaining to WinForms, WPF, and console programming.
Assuming that you are doing something to a Web Form and that you are attempting to press an HTML Button or perhaps a Web Form Control, did you check for the IsPostBack property for the page within the page/view logic there? If not, then you are repeatedly reproducing the identical page again and again. Which is what you appear to describe. A basic article describing this effect of not checking IsPostBack can be read within this basic CodeProject article[^].
I hope this points you in the right direction toward fulfilling your quest for an answer.
|
|
|
|
|
Hi anybody,
I have written DLL library in C with C function:
__declspec(dllexport) int ANB_Printf(ANB_DATAGRAM *dgram, uint8_t cmd_if_ack_nak, FILE *stream)
{
...
fprintf(stream, "* LineNo : %u\n", uint32_val);
...
}
Function ANB_Printf() writing to C FILE stream passing in function as pointer on FILE structure named *stream.
How can I DLL import and use this function considering FILE *stream parameter passing in C#:
[DllImport("anb_protocol_lib.dll")]
public static extern int ANB_Printf([MarshalAs(UnmanagedType.Struct)] ref ANB_DATAGRAM dgram, uint8_t cmd_if_ack_nak, ??? stream);
I would like use passed "stream" parameter as FileStream instance in C# and redirecting this to text file.
Thank you for your suggestions
Milos
|
|
|
|
|
The FILE structure is a C library construct and cannot be used directly in a C# program.
You will have to pass the underlying file handle instead. Then use one of the appropriate FileStream constructors to create a FileStream object from the handle.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Newbie here! I hope I have posted in the write section.
I have been stuck on a socket response and need some help.
I am able to receive the full StringBuilder response for the AsyncCallback if I place a break-point right after the:
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
But if I don't put a break-point in, the code just rips past it and nothing seems to happen and the items are not inserted into db.
Code here:
private static void Receive(Socket client)
{
Logger logger = new Logger();
string responseMSG = string.Empty;
DateTime recTime;
string tracer;
string message;
StateObject state = new StateObject();
state.workSocket = client;
Thread.Sleep(500);
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
if (state.sb.ToString() != "")
{
responseMSG = state.sb.ToString();
if (responseMSG.Length > 77)
{
if (responseMSG.Substring(77, 4) == "2610")
{
recTime = DateTime.Now;
tracer = responseMSG.Substring(126, 6).ToString();
message = responseMSG.Substring(77, responseMSG.Length - 77);
SQLHelper.AddMessageDataToExtractTable("recv", recTime, tracer, message);
}
}
else
{
CurrentState.CurrentReceiveTime = DateTime.Now;
CurrentState.CurrentReceiveTracer = "No Tracer";
CurrentState.CurrentReceiveMessage = responseMSG;
}
}
}
private static void ReceiveCallback(IAsyncResult ar)
{
//Logger logger = new Logger();
try
{
StateObject state = (StateObject)ar.AsyncState;
Socket client = state.workSocket;
int bytesRead = client.EndReceive(ar);
if (bytesRead > 0)
{
state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));
client.BeginReceive(state.buffer, 0, state.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
}
else
{
if (state.sb.Length > 1)
{
response = state.sb.ToString();
}
receiveDone.Set();
}
}
catch (Exception e)
{
//logger.DoLog(string.Format("{0}{1} ", DateTime.Now.ToLongTimeString(), " ReceiveCallback: " + e.ToString()));
}
}
|
|
|
|
|
I have not tried this myself, but your async routine makes no allowance for the fact that network messages can be broken into chunks, so you cannot guarantee that all the data is received in one go.
|
|
|
|
|
Thanks for the response Richard.
Any recommendations?
|
|
|
|
|
As I said, I have not tried this myself. But you need to check the documentation to see when the response event is executed, and how to tell when you have received all the data.
|
|
|
|
|
Hi
I have converted a word document into an image using c# code , the image created using code is showing transparent background in some image format and showing black back ground in some formates
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Word;
using System.Drawing.Printing;
string startupPath = @"C:\Users\infoobjects\Desktop\";
string filename1 = "Test1.doc";
var docPath = Path.Combine(startupPath, filename1);
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
test.messageclass.MessageFilter.Register();
app.Visible = true;
var doc = app.Documents.Open(docPath);
doc.ShowGrammaticalErrors = false;
doc.ShowRevisions = false;
doc.ShowSpellingErrors = false;
if (!Directory.Exists(startupPath + "\\" + filename1.Split('.')[0]))
{
Directory.CreateDirectory(startupPath + "\\" + filename1.Split('.')[0]);
}
foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
{
foreach (Microsoft.Office.Interop.Word.Pane pane in window.Panes)
{
pane.View.DisplayBackgrounds = true;
for (var ii = 1; ii <= pane.Pages.Count; ii++)
{
var page = pane.Pages[ii];
var bits = page.EnhMetaFileBits;
var target = Path.Combine(startupPath + "\\" + filename1.Split('.')[0], string.Format("{1}_page_{0}", ii, filename1.Split('.')[0]));
try
{
using (var ms = new MemoryStream((byte[])(bits)))
{
var image = System.Drawing.Image.FromStream(ms);
var pngTarget = Path.ChangeExtension(target, "Wmf");
image.Save(pngTarget, System.Drawing.Imaging.ImageFormat.Wmf);
}
}
catch (System.Exception ex)
{ }
}
}
}
doc.Close(Type.Missing, Type.Missing, Type.Missing);
app.Quit(Type.Missing, Type.Missing, Type.Missing);
test.messageclass.MessageFilter.Revoke();
I have also tried to recreate the same image with diff background, some results
I would appreciate any feedback as to where I'm going wrong...
|
|
|
|
|
What format(s) do you wish to use the Word Document =>Image in ? How do you wish the background to appear ?
How is what is happening now a problem for you ?
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
You mentioned that the background is sometimes transparent and at other times not in different formats. Not all image formats are transparent.
Some use a special first pixel to define a special color as transparent which is only useful in 256 color (or less) images. These formats (like GIF) provide a chunky pixel-like transparency; however something like a high color photo will usually need a format that has an alpha layer which can provide varying degrees of transparency. The latter format (like PNG) can do what is called alpha-blending against a grey scale alpha channel.
Hope this helps....
|
|
|
|
|
how to merge two datagridview's into one
|
|
|
|
|
How to implement frozen property for datagridview to fix columns to the right
|
|
|
|
|
|
HI,
Everybody,
I want to know that what is stack and heap in C#?What is it's difference???
Thanks...
In Advance...
|
|
|
|
|
Pick up any C# book, or use Google.
|
|
|
|
|
They are both memory, but...
THe Heap is a big chunk of memory (up to the max that your system can provide) that is used to allocate objects via the new keyword: whenever you allocate a class instance (rather than a struct) you are creating the actual object on the Heap, where it will remain until the Garbage Collector decides it is no longer being used and recycles the memory back into the "pool" of available Heap memory. This means that any object has the potential to be accessed anywhere in your application once it has been created.
The Stack is different: it's a lot smaller (typically 1MB for Windows apps, 256 KB for 32-bit ASP.NET apps and 512 KB for 64-bit ASP.NET apps) and it is part of the Thread that is executing. It's also allocated differently: imagine a stack of coins. When you enter a method, you place a little piece of paper on the top of the coin stack, and every time you create a variable (value type or a reference to a reference type) you add a coin to represent the new variable. When you leave the method you remove the piece of paper, and all the coins above it. That's roughly how the stack works: which means that any variable on the stack is available only until the method exits at which point it is destroyed immediately.
So:
public MyClass MyMethod(string name, int count)
{
int realCount = count + 1;
MyClass val = new MyClass();
val.Name = name;
val.Count = realCount;
return val;
}
public MyClass MyMethod(string name, int count) You enter the method, and insert your piece of paper.
int realCount = count + 1;
You create a value type variable on the stack called "realCount" and assign it a value. Add a coin to your coin stack
MyClass val = ...
You create a MyClass reference variable on the stack called "val" - this is a simple variable that can hold only a reference to a MyClass instance, but as yet contains nothing at all. Add another coin to your coin stack.
... = new MyClass(); You create an instance of MyClass on the Heap and assign the reference to it to "val".
val.Name = name;
val.Count = realCount;
Now, you can use the reference in "val" to access the MyClass properties and methods.
return val;
You return the reference to the MyClass instance to the method that called MyMethod
}
You exit the method.
At this point the "piece of paper" and all the coins above it.
"val" and "realCount" are no longer accessible by anything because the stack memory has been reclaimed - but the MyClass instance you created still exists on the Heap and can be used by the method that called MyMethod.
The next call to any method will reuse the same stack memory locations for it's variables that MyMethod used for "val" and "realCount".
Make any sense?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You should write a book!
Regards,
Rob Philpott.
|
|
|
|
|
I think that he did just write a book. LOL....
|
|
|
|
|
imho the "best explanations" of .NET memory allocation using Stack and Heap are contained in three blog entries by Eric Lippert (a "major player" in the creation of .NET, and a very articulate writer): [^], [^], [^].
If these three articles were a movie, I'd give it the tag-line: "Memory moves in mysterious ways."
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
am new to c# programming and for 3 months i've been learning and writing an application which am almost done, i have my user authen table for login purpose,profile table, features table, actions table as well as permission table in place in Msql database and also successful in inserting new permissions to database from winform and assigning those profile to a user. what am left to do is give permission right to users logon to access certain controls on my numerous winforms. am actually stuck here and dont know how to link application to read from database what permissions was assigned to a user and what controls to deny or permit. any help as to how to achieve this would be appreciated thank you.
Question is how do i make application read permission already assigned to a user and block or enable a control based on permissions assigned to that user.
|
|
|
|
|