|
hi,
look at following code:
Hashtable objHash = new Hashtable();
ArrayList objList = new ArrayList();
foreach (DataRowView obj in listBox1.Items)
{
objHash = new Hashtable();
objHash.Add("FirstName",obj[1]);
objHash.Add("EmployeeID", obj[0]);
objList.Add(obj[0]);
}
comboBox1.DisplayMember = "FirstName";
comboBox1.ValueMember = "EmployeeID";
comboBox1.DataSource = objList;
-------
objList has 10 items ,although combobox filled with 10 items but display these items as "[Collection]"...........then how can get the display member from these "[Collection]"
|
|
|
|
|
Try this :
Hashtable objHash = new Hashtable();
ArrayList objList = new ArrayList();
foreach (var obj in listBox1.Items)
{
objHash = new Hashtable();
objHash.Add("FirstName", obj);
objHash.Add("EmployeeID", obj);
objList.Add(obj);
}
comboBox1.DisplayMember = "FirstName";
comboBox1.ValueMember = "EmployeeID";
comboBox1.DataSource = objList;
|
|
|
|
|
Hi all,
I have been trying to change the backcolor of specific rows depending on a condition,but when the condition is met the entire grid color changes.
I already tried this and many more like this but none of them work,
DataGridViewCellStyle style2 = new dataGridViewCellStyle()
style2.BackColor = Color.Red;
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;
There is something which I am doing wrong. Please help me to fix this.
|
|
|
|
|
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;
dataGridView1.Rows[index].DefaultCellStyle.BackColor = Color.Red;
And your index can change depending on your condition.
[Edit]
And if you want to change multiple rows BackColor:
DataGridViewSelectedRowCollection coll = dataGridView1.SelectedRows;
foreach (DataGridViewRow row in coll)
row.DefaultCellStyle.BackColor = Color.Red;
[/Edit]
When you're alone in the Dark, Fear will protect you...
modified on Sunday, November 2, 2008 8:41 AM
|
|
|
|
|
Hi Pedram ,
I tried this as well it does not work,
first I selected all rows which meet the specified condition
This is just to show the selection, Its alternate rows here
but in real scenario its any random row.
int yyy = 0;
foreach (DataGridViewRow rowss in dataGridView1.Rows)
{
if (yyy % 2 == 0)
{
rowss.Selected = true;
}
else
{
}
yyy++;
}
, then I used your or each statement but still I get the same results. There is no color on the datagridview. This Datagridview is placed on a user Object and It is added on a form at the run time.Does it make any difference ?
Regards
Omer
|
|
|
|
|
But following completely worked for me:
int y = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (y % 2 == 0)
row.Selected = true;
y++;
}
DataGridViewSelectedRowCollection coll = dataGridView1.SelectedRows;
foreach (DataGridViewRow row in coll)
row.DefaultCellStyle.BackColor = Color.Red;
But why did you act like that? It's O(n) = 2n
You can:
int y = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (y % 2 == 0)
row.DefaultCellStyle.BackColor = Color.Red;
y++;
}
DataGridViewSelectedRowCollection coll = dataGridView1.SelectedRows;
foreach (DataGridViewRow row in coll)
row.DefaultCellStyle.BackColor = Color.Red;
Member 3953856 wrote: .Does it make any difference ?
I don't think so. You should just point to your DataGridView correctly.
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
Put your code into the cellformat event of the datagridview
|
|
|
|
|
Yes ,
putting the code on the cell formatting event of the datagridview worked, I mentioned that I was using a user control. The data grid was on the User control.
If not a user control then the other stuff works fine.
thanks
|
|
|
|
|
I have a data gridview on my form. Some Columns have format specification as N2, means that
numeric format with 2 decimal spaces.
I set my thread CurrentCulture to German locale then fill the datagridview with data,
trough dataset offcourse.
Setting the current culture as follws
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-de");
I expect to see the formatted colon in German locale setting, decimal values with "," separator,
but I don't. I still see them in Enlish locale.
Those columns are defined as DOUBLE in MySQL database as well.
What is the reason?
Thanks to everybody,
Muharrem
|
|
|
|
|
hi all,
I have ListBox where are 10 items. i set
ListBox.DisplayMember = "FirstName";
ListBox.ValueMember = "EmployeeID";
then ListBox shows the Employee's FirstName.My problem is that how do i get the all EmployeeID from ListBox?
|
|
|
|
|
|
Hi ...
I think it's good for you:
List<int> val = new List<int>();
for (int i = 0; i < listBox1.Items.Count; i++)
{
lst.SelectedIndex = i;
val.Add((Int32)lst.SelectedValue);
}</int></int>
In val you have All EmployeeIDs ...
But this code is not logical code ...
if(Human.live)
{
Human.peaceful = false;
while(true)
{
Human.love(Human girl, Human Boy);
}
}
|
|
|
|
|
i found
ArrayList objList = new ArrayList();
foreach (DataRowView obj in listBox1.Items)
{
objList.Add(obj[0]);
}
|
|
|
|
|
You should rather use a generic list (The ArrayList class is practically deprecated):
List<object> objList = new List<object>(listBox1.Items);
or just get a reference to the Items collection:
ListBox.ObjectCollection objList = listBox1.Items;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi
I want use DFS algorithm for maze (with all paths).
Please write for me one sample DFS code.
with many thanks...
|
|
|
|
|
|
Are bhai yahan be code nahi dete he.... bahat bure log he.
|
|
|
|
|
sitnet wrote: Please write for me one sample DFS code.
This isn't the way this site works. You seem to be mistaking us for rentacoder. Here's how it works - you work out what you need to do, you type in some code and we help you with the bits you can't get. We don't write assignments for you.
|
|
|
|
|
<br />
var visitor = new PathCollectingVisitor();<br />
graph.DepthFirstTraversal(visitor, start);<br />
|
|
|
|
|
Hi everyone, I'm developing an application that has a full control on another windows application.
Let me tell you about my story. I have an windows application(lets say "App A") which is very difficult for blind users because its GUI is so bad that the blind cannot use it even though they have a screen reader , but I cannot modify it at all since I don't have the source code of App A. So I decided to develop another windows application in C#(lets say "App B") which is easier to use. App B's task is only to get inputs from a user and then send those inputs to App A for processing. You may wonder why I have to send inputs to App A, why doesn't App B do everything by itself. The reason is that App B isn't able to do the main process as App A can since I don't have App A's code so I don't know how to do the main process.
Now I can send many commands by App B to App A via "SetForegroundWindow" and "SendKey" method, so I can order to click any button in App A or fill any textbox in App A and so on. But the problem is that I don't know how to grab the outputs which App A returned(all outputs are just text).
My current solution is to send "Ctrl C" to grab the output texts of App A and then use "Clipboard" to bring them into App B, but I think there must be a better solution than using "Ctrl C" and "clipboard". I had searched for the better solution, then I found many applications that can grab all the texts in any windows application. Unfortunately, they are for sale not for free, but I don't want to buy them, I want to grab text in another application by myself.
So, does anyone know how to grab texts which are displayed on another windows application ?
Please tell me, thank you very much.
|
|
|
|
|
Most of it can be done using some WinAPI calls. For grabbing text, you can use the GetWindowText[^] API call. This should work fine for button captions, label texts and many other controls.
For controls like list boxes you might first need to get the items in that listbox, which can be done using SendMessage with the appropriate parameters. They're all documented in MSDN, so you may need to pick the ones that work with your application.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I've tried using GetWindowText and I found that it can only grab a text on Window Title, it cannot grab texts on button caption, label and so on. Do you have another solution ? By the way, thank you for your help
|
|
|
|
|
According to MSDN:
To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
So you might try to do a SendMessage(Handle, WM_GETTEXT, ..., ...) to the other control.
If I remember correctly this has worked for me in the past.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
AxSHDocVw.AxWebBrowser axWebBrowser1;
I am making a web editor(wysiwyg editor).
My program has a toolStrip and axWebBrowser control
When I want to change the font of the webbrowser, select my comboBox on toolStrip, it make the font change but the FOCUS Remain in Font ComboBox.
I want give the focus to axWebBrowser programmically.
here is the code that executed when the ComboBox SelectedIndex changed
case 32:
doc1.execCommand("FontSize", false, (object) ((ToolStripComboBox)sender).SelectedItem.ToString().Split('(',')')[1]);
Win32.SetForegroundWindow(axWebBrowser1.Handle);
Win32.SetFocus(new System.Runtime.InteropServices.HandleRef(null, axWebBrowser1.Handle));
please take care of my question. thanks a lot.
|
|
|
|
|
Hello,
Have you tried:
axWebBrowser1.Focus();
It worked for me. Hope it helps.
Jason.
|
|
|
|