|
So that I ensure I have only 1 PictureBox for each coordinate.
In a List I could end up having with 2 PictureBox es having the same coordiantes.
Xmen wrote: what that mean ?
When you assign the Image property of a PictureBox , you can only assign the whole image, in my case that would be the whole 256x2000 pixel source image.
What I want is to split that image into 32x32 pixel tiles and assign each of these tiles to a different PictureBox , so you can click on and select each separately.
Then you can paste the 32x32 tiles and build your map with them.
|
|
|
|
|
Megidolaon wrote: So that I ensure I have only 1 PictureBox for each coordinate.In a List I could end up having with 2 PictureBoxes having the same coordiantes.
That mean you are scaring to write a little more code that will validate. Its quite simple, if you dont want to put multiple pictureboxes at same point then you can just iterate through previous pictureboxes' location. BTW I dont think you will get same point again if you try to write a good code (No need for validation)
Megidolaon wrote: When you assign the Image property of a PictureBox, you can only assign the whole image, in my case that would be the whole 256x2000 pixel source image.What I want is to split that image into 32x32 pixel tiles and assign each of these tiles to a different PictureBox, so you can click on and select each separately.Then you can paste the 32x32 tiles and build your map with them.
2000 cant be divide by 32, your image must have 2048 height if you gonna tile of 32 x 32
OoO Well, once I wrote a code similar to this but I just used a single PictureBox.
What you need to do is use the MouseClick events of PictureBox. In MouseClick, grab the cursor position, round the position to least tile position and rip it from image.
eg
Cursor Position : 35, 126
Nearest Tile Position(by rounding) : 32, 96
If you are unable to write code to round, just give a bell
An advice, do not set Image in Image property, use BackgroundImage instead, therefore you can use BackgroundImageLayout and avoid lots of hassles.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
As for the PictureBox coordinates, I program by the motto "better save than sorry".
I try to avoid even theoretically impossible situations, like slightly wrong named files (since I'm the only one that names the files), even if such a situation should never happen, I know in the rare case it does (if I forgot the guidelines I made up or whatever), the program will still work fine.
The dictionary works god, I'll just leave it lie that.
Xmen wrote: 2000 cant be divide by 32, your image must have 2048 height if you gonna tile of 32 x 32
I use the Math.Ceiling() method to add enough PictureBox es to contain images that aren't dividable by 32 and the Image property of the PictureBox es at the edges should contain the last bit of the source image.
I want to keep the source image size a bit flexible.
Xmen wrote: Cursor Position : 35, 126
Nearest Tile Position(by rounding) : 32, 96
I already used the MouseDown event to determine which PictureBox was clicked on and changed its BorderStyle .
I laos determined whichPictureBox was last clicked on and changed its BorderStyle back to None , to highlight only the one you clicked on last.
Xmen wrote: An advice, do not set Image in Image property, use BackgroundImage instead, therefore you can use BackgroundImageLayout and avoid lots of hassles.
I used
pictureboxes[coordinate].BackgroundImageLayout = ImageLayout.Tile; and tried all available ImageLayout s, with an without my own code.
All PictureBox es were white and I had a weird smear effect where the the Borders of the PictureBox es smeared about an inch on the right side of the form, outside the FlowLayoutPanel.
I got it right now, I adjusted my loops and changed a bit, the PictureBox es were all over the place, with some not even being displayed (I found that out by numbering a few), but now everything is fine.
I even painted the last PictureBox es first with the BackColor of the form (through a Pen 's Brush property) and now it looks like only the source image is displayed.
|
|
|
|
|
Since you got it work, no further answers
if you wanna check mine one, here is the link[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks a lot, you helped me a great deal.
I had a problem with the FlowLayoutPanel , which kept me from displaying the PictureBox es properly, the FlowLayoutPanel overrides the actual location and changes it according to FlowLayout .
I switched to a normal Panel .
I had a problem where even when setting the AutoScroll peroptery to true, it woudn't add any scrollbars, even if I had many more PictureBox es then could be displayed at once.
However, I copypasted a Panel from a codeproject article (seemingly the same as mine) and suddenly it worked.
Now my Panel doesn't change the location and adds scrollbars that allow you to scrll arund if the amount of PictureBox es is too large to display at once.
modified on Monday, March 2, 2009 6:07 AM
|
|
|
|
|
Megidolaon wrote: which kept me from displaying the PictureBoxes properly
is it public ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
It was private and so were the Panel , I used at first and the Panel , that I use now and which works.
|
|
|
|
|
Now that it works I have a new problem.
The MouseUp event for a PictureBox gets fired the moment I click on a PictureBox .
The problem is that I'd use it allow the user to select multiple tiles while the mouse button is held down and paste them onto the map tiles, again while the mouse button is held down.
If the MouseUp event gets fired without actually releasing the mouse button, this is not possible.
Is there any way around this?
|
|
|
|
|
Good day All
i have a Following Arraylist that carries the List of Arraylist Values of String type. I want to Disable a Cell that does not match with the Values in the Arraylist.
ArrayList arr = Disable_Grid();
foreach(arr in ultraGridCycles)
{
;
}
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
You have not supplied sufficient information.
Vuyiswa Maseko wrote: I want to Disable a Cell
What cell?
Vuyiswa Maseko wrote: does not match with the Values in the Arraylist.
There are many values in the array list. Are there many values in each cell?
Do you want to hide cells where the value of the cell is not contained within the ArrayList?
Finally, are you using .NET 1.x? If not, then why are you using an ArrayList.
|
|
|
|
|
Colin Angus Macka wrote:
What cell?
A Grid is made up of Columns and Rows. Like in in Excel we have Cells in a Gridview.
Colin Angus Macka wrote:
There are many values in the array list. Are there many values in each cell?
Yes, The Grid will be Populated with Values like
1234<br />
And in the Arraylist you might Find that there is 4. Now i want to Disable the cell that is carrying the values "123"
Colin Angus Macka wrote:
Do you want to hide cells where the value of the cell is not contained within the ArrayList?
Yes
Am Using .NET 2.0
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
How about using a HashSet instead?
(No one uses Arraylist anymore anyway.)
|
|
|
|
|
That Wouldn't be a problem. I have changed from Arraylist but not to HashSet , am using 2.0 not 3.5
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
In my opinion HashSet is the only reason to use 3.5, if it weren't for that I'd still 2.0 as well.
Are you using a Dictionary then? That's what I use in my Set[^] class.
|
|
|
|
|
Hi!
i know people have asked a lot about comboboxes but it's not really about how to get the value or index or whatever.Let me explain.it's users access management application with users, roles and rights:
i have a form editRight with 2 combobox cmbUsers to list users and cmbroles to list role of each users and 3 listboxes.let's pause here
on load event i fill users combobox with users
private void EditRight_Load(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
dt_users = UserManager.FindAll().Tables[0];<br />
cmbUsers.DataSource = dt_users.DefaultView;<br />
cmbUsers.DisplayMember = "user_name";<br />
cmbUsers.ValueMember = "user_id";<br />
<br />
CallFillRoleCombo((int)cmbUsers.SelectedValue);<br />
}<br />
catch (System.Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
<br />
private void CallFillRoleCombo(int uid)<br />
{<br />
try<br />
{<br />
dt_roles = UserRoleManager.FindByUser(uid).Tables[0];<br />
<br />
cmbroles.DataSource = dt_roles.DefaultView;<br />
cmbroles.DisplayMember = dt_roles.Columns[2].ToString();<br />
cmbroles.ValueMember = dt_roles.Columns[1].ToString();<br />
}<br />
catch (System.Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
<br />
}<br />
<br />
private void cmbUsers_SelectedValueChanged(object sender, EventArgs e)<br />
{<br />
CallFillRoleCombo((int)cmbUsers.SelectedValue);<br />
}<br />
when i run the code its throws exception:Object reference not set to an instance of an object.It seems that its calling the cmbUsers_SelectedValueChanged eventhandler when setting the display member of the cmbUsers combobox.
How to work around it?Thank you for reading this.
eager to learn
|
|
|
|
|
In the following code for loading data in user combobox
unsubscribe the event cmbUsers_SelectedValueChanged and after filling data
subscribe again
private void EditRight_Load(object sender, EventArgs e)
{
try
{
dt_users = UserManager.FindAll().Tables[0];
cmbUsers.DataSource = dt_users.DefaultView;
cmbUsers.DisplayMember = "user_name";
cmbUsers.ValueMember = "user_id";
CallFillRoleCombo((int)cmbUsers.SelectedValue);
}
}
hope this works for you!
|
|
|
|
|
got your problem
try this
private void cmbUsers_SelectedValueChanged(object sender, EventArgs e)
{
if (comboBox2.SelectedValue.GetType() == typeof(int))
CallFillRoleCombo((int)cmbUsers.SelectedValue);
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks guys for replying this post.Really apreciated it.The method that worked for me is the one suggested by deep@Pune.Thanks
eager to learn
|
|
|
|
|
your most welcome!!
yersterday I forgot to include actual lines in the code to subscribe and unsubscribe the event!!
soru for that!!!!!
|
|
|
|
|
Hi ,
I need some sample code that populates the checkBoxlist(C# Windows Application) based on the table values present is a SQL server database table.?
Someone help in this regard..
Thanks in Advance,
Balaguru
|
|
|
|
|
|
Hi evryone
How can i make pdf from cristal report - in C# code (dont whant to see hem) ?
thank's
|
|
|
|
|
|
Hi all. I'm sure there are loads of articles and examples on the net for what I'm trying to do but I don't know what you would call it and consequently I'm not sure what to Google for.
I'm trying to simplify a file path to something that will fit into a certain number of characters. I think I can best explain by using an example.
Let's say I have a file path as follows:
C:\Documents and Settings\My Name\My Documents\Work Documents\Business Plan.doc
but I have only limited space to display this path. I'm not overly concerned that the user should be able to read the full path (although I can do that by providing a ToolTip or putting the full path in the StatusStrip or whatever) but I would like for the user to get a general impression of where the path points.
I am in other words looking for a result along the lines of:
C:\Docum...\...\Business Plan.doc
If you have any suggestions for articles or examples on the net that deal with this I'd be happy to hear. Also, the above sample result is what I quickly came up with but there may be more sensible ways of stripping down long paths to something shorter. Please let me know if you have any advice.
|
|
|
|
|