|
Hello,
I want to get the unicode of some chars to send them to a cellphone
EX:
0628 represnt the char 'ب' in Arabic iwant to get this 0628 from this letter.
thanks
Dad
|
|
|
|
|
For each character in the string this displays:
The character
It's unicode character code in hex
It's unicode character code number
string text = "0 a+…"";
foreach (char c in text)
{
Console.WriteLine("{0} U+{1:x4} {2}", c, (int)c, (int)c);
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Chars already are in unicode
|
|
|
|
|
My Question,
I have designed FORM1 with a datagridview dgvForm1 and am populating data into it using LINQ queries. The data is populating fine into the dgvForm1.
I have a checkbox column in the dgvForm1 to select the checked rows.
I have a button in FORM1 called DISPLAY.
I have FORM2 with datagridview dgvForm2.
All I want to do is ...allow the user to select the required rows from dgvForm1 using checkboxs. After selecting, the user clicks on the DISPLAY which will show FORM2 . I want to display the selected rows from dgvForm1 in the datagridview(dgvForm2) of FORM2.
Am using C# with VS 2008 , this my code for reading the checked value of rows,,,, I have defined a constructor in Form2 to take in string values. Then in form2 initialization am assigning the string value to datagridview2 in form 2.. Am not sure if its correct to do so ..... but am not getting the required result.i.e my datagrid2 is not getting populate with the checked rows from datagrid1. please suggest solutions,,,thanks
string<br />
<br />
data = string.Empty;<br />
foreach (DataGridViewRow row in dataGridView1.Rows<br />
{<br />
if (row.Cells[SelectColumnIndex].Value != null &&<br />
Convert.ToBoolean(row.Cells[SelectColumnIndex].Value) == true)<br />
{<br />
foreach (DataGridViewCell cell in row.Cells)<br />
{<br />
if (cell.OwningColumn.Index != SelectColumnIndex)<br />
{<br />
data += (cell.Value + ","); <br />
}<br />
}<br />
data += "\n";<br />
}<br />
}<br />
Form2 fm = new Form2(data);<br />
fm.Show();<br />
<br />
}<br />
<br />
<br />
public Form2(String data) <br />
<br />
{<br />
<br />
InitializeComponent();<br />
<br />
this.dgv1Fm2.DataSource = data; <br />
<br />
<br />
<br />
<br />
<br />
}<br />
<br />
|
|
|
|
|
I would suggest an alternative strategy.
Instead of a string for your data member use a List<> .
Then for each selected row add the primary index value to the List<>.
Pass the data to Form2, in the constructor, as you do now and then load data into the dgv using a SELECT statement, passing in the items from the List<> as parameters for a WHERE clause.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Is there any easier way....to display selected data from form1 dgv using checkbox...and diaplay in dgv of form2
|
|
|
|
|
spankyleo123 wrote: Is there any easier way
Depends on what you call easy!
It also depends on what you want to do with the data in Form2. If it is read only then you could create a class (I'll refer to it as SelectedData ) that has fields for each of the columns of interest from your data, give it a Constructor that takes a DataGridViewRow and load the fields from the dgvRow in the Constructor .
You could then go through your dgv and for each selected row create an instance of SelectedData with the DataGridViewRow and add it to a List<selecteddata>.
Pass the filled List to Form2 and simply set dgvForm2.DataSource to the List<>.
If you need to edit the data in Form2, my previous suggestion, or a variation of it, would be preferable.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi
I am trying to take screenshots from DirectX Games and I successfully take screenshots most of the time. But sometimes my screenshots come out completely black.
Here is the code I am using to take screenshot:</b>
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);
A global solution to take screenshots would be great (for desktop - for DirectX and OpenGL games).
Thank you.
|
|
|
|
|
How can i insert to list/array an object to the right place by some comparison function and in the end of the process to get back the best 100 object?
for example if i have this code:
<br />
class Example : IComparable<br />
{<br />
public double num1;<br />
public double num2;<br />
public double GetIt<br />
{<br />
get<br />
{<br />
return num1 * num2;<br />
}<br />
}<br />
<br />
public double SomeValue()<br />
{<br />
double result = this.num1 * this.num2 - this.num1 / (this.num2 + 1);<br />
return result;<br />
}<br />
<br />
#region IComparable Members<br />
<br />
public int CompareTo(object obj)<br />
{<br />
Example e1 = (Example)obj;<br />
int res = (this.SomeValue() - e1.SomeValue()) > 0 ? 1 : -1;<br />
return res;<br />
}<br />
<br />
<br />
#endregion<br />
}<br />
<br />
class UsingExample<br />
{<br />
public List<Example> m_List;<br />
<br />
public UsingExample()<br />
{<br />
m_List = new List<Example>();<br />
for (int num1 = 1; num1 <= 100; num1++)<br />
for (int num2 = 1; num2 <= 100; num2++)<br />
{<br />
Example e1 = new Example();<br />
e1.num1 = num1;<br />
e1.num2 = num2;<br />
m_List.Add(e1);<br />
m_List.Sort();<br />
<br />
if (m_List.Count > 100)<br />
m_List.RemoveAt(100);<br />
}<br />
<br />
<br />
}<br />
public Example this[int num]<br />
{<br />
get { return this.m_List[num]; }<br />
}<br />
<br />
<br />
}<br />
<br />
The problem is that every time i need to sort all the list. What is the best way to do it in C# by this process:
1. Insert an object to Sorted Array/List in the right place.
2. If the Current Instance of an object is Smaller then the biggest object in the 100 small object list (by Some IComparable functions):
2.1 Remove the biggest object from the list.
by This process i want to remaine with the smallest object in 100 list.
what is the best way to do it because i don't want to sort the Array every iteration if the Array/List is allready sorted.
|
|
|
|
|
How about a System.Collections.Generic.SortedList<T> ?
See here[^]
(But it seems to say that it can't contain duplicate keys. Might you have duplicates?)
Also, you wouldn't need to sort after each insert, only before retrieving.
modified on Sunday, July 26, 2009 10:48 AM
|
|
|
|
|
Yes , i don't have key as the value of the function. It can be the same value and this is the reason that i can't Use SortedList<>, Is there another way?
|
|
|
|
|
There's always another way.
If there's a duplicate for highest value, which would you remove? Or contain both?
Do you want 100 items or all the items with the bottom 100 values? Or would it matter?
|
|
|
|
|
I want to have all the 100 items with the best result even if all of them have the same value. (Its very big range of data , more then 10^50 Items) And i want the best 100 items.
What should i do?
modified on Sunday, July 26, 2009 12:39 PM
|
|
|
|
|
But what if items 95 - 105 all have the same value? Does it matter which ones you discard?
|
|
|
|
|
In This case i does not matter, You can just save the first one : (Example of the result)
1. 0.212132
2. 0.23
3. 0.23
4. 0.3
.
.
.
96. 2.299
97. 2.299
98. 2.3
99. 2.3
100. 2.3
|
|
|
|
|
bonzaiholding wrote: more then 10^50 Items
Stop right there, no need to optimize anything, there isn't enough life in your PC to ever finish such a job, provided you would be willing to pay for the energy it will take.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
But they're very small items. Waffer thin.
|
|
|
|
|
I think you can do it this way.
In the loop, first collect the values (without sorting) in a list up to a certain number, say 1000 values. When it reaches 1000 values, re-sort the list and keep only the top 100 using GetRange(). Then continue adding to the list. This will prevent the algorithm from sorting all the time while keeping memory usage limited. The number 1000 should be a variable and you should experiment with it to find a value that gives you the best performance.
In your example:
int maxSize = 1000;
for (int num1 = 1; num1 <= 100; num1++)
for (int num2 = 1; num2 <= 100; num2++)
{
Example e1 = new Example();
e1.num1 = num1;
e1.num2 = num2;
m_List.Add(e1);
if (m_List.Count >= maxSize)
{
m_List.Sort();
m_List = m_List.GetRange(0, 100);
}
}
m_List.Sort();
if (m_List.Count > 100)
{
m_List = m_List.GetRange(0, 100);
}
I must agree though, doing this 10^50 times is impossible. Your computer does something in the order of 10^9 processor instructions per second, per day say 10^14, per year say 10^16, in a hundred years 10^18... (I may be a bit off, but you get the idea..) Or are there any mice involved?
|
|
|
|
|
This is what i did, The problem is that every iteration i need to sort the list that is allready sorted.
The Only thing that i need is to Insert the object into the right place in the sorted list and then Remove the last object on the list.
Do you have any idea what can i do?
modified on Monday, July 27, 2009 7:27 AM
|
|
|
|
|
With the solution I propose, this is not the case. You would only sort every so often, not with every iteration. Now I think about it, this may still be slow, because you would have to sort a larger list.
I suppose you could also use a LinkedList (for fast insert/remove) and implement some kind of binary search to find the index to insert at. LinkedList doesn't seem to have a BinarySearch() method, but I'm sure you can find an example of binary search somewhere. I think that would give you the best performance.
|
|
|
|
|
You still don't get it, do you?
assuming a fantastic CPU that does everything your algorithm needs for one iteration in a single instruction (waw), and runs at 1000GHz (waw), so it does 1 of your zillion things per picosecond, or 3E19 per year (as there are 3E7 seconds in a year); now assume it started when the universe started (some 14E9 years ago?), then it would now have finished some 4E29 thereof, way less than 1E50 (you're twenty zeroes short).
so sorting isn't relevant, your algorithm stinks, it is just undoable that many times.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
The Might and Magic V Map Editor's floating Toolbar with TabPage as below:
http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/Visual%20C%7C3/MapEditor%7C_Might%20and%20Magic%20V%20Map%20Editor.JPG
How do I design the same toolbar in Visual C# 2008?
|
|
|
|
|
Here is an Nice Example of Floating Toolbar. You have to design the internal content of Toolbar.
Floating Toolbar
modified on Sunday, July 26, 2009 12:44 PM
|
|
|
|
|
|
I have a list of specific class.
Im doing some simulation and i want to receive in the end the 100 best result.
Lets say i have this class :
class A<br />
{<br />
int j;<br />
int t;<br />
<br />
}
and i want to save in some range of j and t the best 100 "A" elements that give me the low math.pow(j/t,2) (100 result of the lowest A that i have).
Right now im insert the result to the list and then sort the list with the Compare method. each time a take the smallest result of the list and then if the current result is more small then then the small one on this. If its is smallest then i insert it into the the array , sort it and then remove the last object and continue.
What is the best way to take a List/Array of sort element and just insert the Current element to it's place in the sorted List/Array and remove that biggest element of the list ? (In C# )
modified on Sunday, July 26, 2009 7:46 AM
|
|
|
|