|
Hi I have a listview on my windows form with a details view. The listview has to columns and many items. These items and subitems are add to the listview in the form load event. The item are also put in s specific order. I then want to find an item in the second column and then select this item and give it focus.
Can anyone give me any suggestions or where I can find good examples of listviews?
Lucy
|
|
|
|
|
|
Hi thank you for the link. I was trying to go about this a different way but I found the answer before your reply using trial and error, Here is my form load event and the last if statement finds the item:
RegistryKey key = Registry.LocalMachine.OpenSubKey("RegKey_test", true);<br />
RegistryKey k = key.OpenSubKey("Classification");<br />
if (k != null)<br />
{<br />
string[] names = k.GetValueNames();<br />
<br />
for (int i = 0; i < k.ValueCount; i++)<br />
{<br />
int values = Convert.ToInt32(k.GetValue(names[i], ""));<br />
ListViewItem item1 = new ListViewItem();<br />
ListViewItem.ListViewSubItem item2 = new ListViewItem.ListViewSubItem();<br />
item1.Text = names[i];<br />
item2.Text = Convert.ToString(values);<br />
item1.SubItems.Add(item2);<br />
listView1.Items.Add(item1);<br />
}<br />
}<br />
<br />
if (key.GetValue("Threshold") != null)<br />
{<br />
string KeyValue = Convert.ToString(key.GetValue("Threshold", ""));<br />
ListViewItem itemFind = listView1.FindItemWithText(KeyValue, true, 0);<br />
if (itemFind != null)<br />
{<br />
itemFind.Selected = true;<br />
listView1.FocusedItem = itemFind;<br />
}<br />
}
I am not sure if this is user friendly yet as the second column of the listview may be taken out so that the values cannot be seen by the user. I would then need a new ways to find the value needed to select the appropriate item.
Lucy
|
|
|
|
|
I am trying to display multiple images in a single picture box control. Any ideas?
a novice
|
|
|
|
|
Your picture box has an image associated with it. The image can be anything including one created in memory. Create a Bitmap (which is a type of image) in memory and draw the multiple other images into it in the appropriate place with the appropriate size.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
If you are going to show more than one images on a single picture box, you may try creating a new image containing all images which you want to show.
Following code will show two images img1.jpg and img2.jpg on the same picture box, by drawing them on a third image; second image will be drawn at the bottom of the first image-
-----------------------------Start Code-----------------------------
System.Drawing.Bitmap MergedImage;
System.Drawing.Image Image1 = Image.FromFile("C:\\img1.jpg");
System.Drawing.Image Image2 = Image.FromFile("C:\\img2.jpg");
if (Image1.Width > Image2.Width)
{
MergedImage = new Bitmap(Image1.Width, Image1.Height + Image2.Height);
}
else
{
MergedImage=new Bitmap(Image2.Width,Image1.Height + Image2.Height);
}
Graphics g = Graphics.FromImage(MergedImage);
g.DrawImage(Image1, 0, 0);
g.DrawImage(Image2, 0, Image1.Height);
this.pictureBox1.Image = MergedImage;
g.Dispose();
--------------------------------------End Code-------------------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Thank you Dave I tried it and it worked perfectly.
a novice
|
|
|
|
|
I am trying to pull a text from a database and display it in the picture box under the images. I am getting errors though. Any idea how I can do that?
a novice
|
|
|
|
|
Alternatively, throw away that PictureBox; use a Panel instead, and in its OnPaint method,
draw the different images with Graphics.DrawImage() at the required positions.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
If I have to create a new form in code, where exactly do I enter the code, or do I need to add a codepage to enter the coding. Please help
Karolis
|
|
|
|
|
karlschm wrote: If I have to create a new form in code, where exactly do I enter the code, or do I need to add a codepage to enter the coding.
It sounds like you really need to pick up a beginners book on C#.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Hi,
i think what you are trying to do here is create a new windows form.
its simple.
open your visual studio.
select windows application
you will get a screen with a form(a blank square)
double click on it,you will get the aread to enter the code.
this is the simplest explanation
check it out any doubts i will be here
j
|
|
|
|
|
Hi J,
Thanks for the help...
This part I understand, however I want to add a form without using the Designer interface or GUI, but from scratch using only code. One way I think I can do this is by adding a code file and then entering the relative code here with to correct imports and using statements. Is this the correct way?
Every source I am searching only explains via the Designer and not from scratch with code.
Thanks for the assistance
|
|
|
|
|
hi all,
im now doing the 'SearchEvent' by date, using asp.net & C# on visualstudio2005,
where the user will search the event by selecting from the 3 dropdown boxes:
dropdownDay, dropdownMonth and dropdownYear.
-example of date in database: 10-Mar-2004
right now, i've encountered some problems displaying my result in the gridview table when i clicked on search.
when i run it, it doesn't displays any table/data at all, unlike my previous 'search by description' which is able to display out.
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + Server.MapPath("myFile..mdb") + ";");
conn.Open();
string query = "SELECT code, description, start_date, start_time, venue FROM Event WHERE start_date = '" + dropdownDay.SelectedIndex.ToString() + "' - '" + dropdownMonth.SelectedIndex.ToString() + "' - '" + dropdownYear.SelectedIndex.ToString() + "'";
OleDbDataAdapter comm = new OleDbDataAdapter(query, conn);
DataSet ds = new DataSet();
comm.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
i would appreciate some help on this code here.
Thanks a lot.
|
|
|
|
|
Hi,
I have an orientation issue,
in my mobile application, in my ListView Whenever I shift from portait to lanscape depending upon the size(height) Its desplaying Horizatal scroll bar,
coz, while calcuating I am unable to catch whether the vertical scroll bar is there are not..
I WANT TO KNOW HOW TO FIND OUT WETHER VERTICAL SCROLLBAR IS DESPLAYYING OR NOT.
Thanks,
Prashanth
|
|
|
|
|
Hi,
This is my code in the form load
string sConnectionString = "Data Source=testingserver2;Initial Catalog=test;User Id=sa;Password =agr2007$ ";
SqlConnection conn = new SqlConnection(sConnectionString);
conn.Open();
SqlCommand comm = new SqlCommand("select ModuleId from Module_Master", conn);
SqlDataAdapter dap = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
dap.Fill(ds);
cmbModuleID.DataSource = ds.Tables["MODULE_MASTER"];
cmbModuleID.ValueMember ="ModuleID";
cmbModuleID.DisplayMember = "ModuleID";
I kept a break point at dap.Fill(ds) and checked. It is fetching the values from the database. But i am not able to populate combo with those values.
Thanks in advance
|
|
|
|
|
Hi,
if you are saying about Dropdownlist then
subramanyeswari wrote: cmbModuleID.ValueMember ="ModuleID";
cmbModuleID.DisplayMember = "ModuleID";
there is not any porperty like this.. I dont Know abt this.
U can do this..
cmbModuleID.DataSource = ds.Tables["MODULE_MASTER"];<br />
cmbModuleID.DataTextField="ModuleID"; <br />
cmbModuleID.DataValueField= "ModuleID";<br />
cmbModuleID.DataBind();<br />
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
thanks for your quick reply. But i am not able to find DataTextField,DataValueField properties and DataBind function for the cmbModuleID combo box.
Regards
|
|
|
|
|
Hi, iam in windows application (with n-tier architecture)
im my application iam designing form with usercontrols and attach the usercontrol to mainform.
myproblem is to print usercontrol form which consists of
lables,panel,textbox and gridview control.
so please help how can i do it?
i also try with codeproject print forms code ,but it is not giving output..(it's not giving any error but it is not displaying only blank page)
with regards
murali krishna
murali krishna
|
|
|
|
|
|
hi
I don't know how i can make a folder that protected from delete
plz help me
regard
|
|
|
|
|
I think this is the third message i've seen on this subject recently. Its either coinsidence or your the same person. Either way, try searching the threads for the previous questions, and use the search box a little ways up not the one at the top of the page.
My current favourite word is: PIE!
I have changed my name to my regular internet alias. But don't let the 'Genius' part fool you, you don't know what 'SK' stands for.
-The Undefeated
|
|
|
|
|
People keep asking for clarification of what you want, yet you refuse to answer them. What makes you think anyone is going to answer your question now??
Check into NTFS security. It's the only thing that's going to "lock" a folder.
|
|
|
|
|
I have created a MDI. I have made form1 as parent form and there are menus like file edit option etc. All the menus on form1 are disabled except file,under file there are other sub menus like login logoff and these menus are enabled too. On click to login sub menu another child form2 is opened. On form2 there is command button control. The question is I need to enable the menus of parent form (form1)by click on the command button of child form (form2). please help me.
keyto
|
|
|
|
|
[^]
Standards are great! Everybody should have one!
|
|
|
|